Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify profiler impl (bubble up Option) #4148

Merged
merged 1 commit into from Apr 28, 2020
Merged

Conversation

Veetaha
Copy link
Contributor

@Veetaha Veetaha commented Apr 25, 2020

No description provided.

@Veetaha
Copy link
Contributor Author

Veetaha commented Apr 25, 2020

Force-pushed due to some rustup connection problem on CI:
https://github.com/rust-analyzer/rust-analyzer/actions/runs/87817092

let label = if enabled { Some(label) } else { None };
Profiler { label, detail: None }
if PROFILING_ENABLED.load(Ordering::Relaxed) {
PROFILE_STACK.with(|stack| stack.borrow_mut().push(label));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes semantics, it’ll return non trivial profiler where the old code would use None label

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by non-trivial profiler, it is just a newtype of Option<Impl>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing from my iPad, so might be wrong, but it still seems to me that the refactoring changes behavior. && was meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I mistakenly thought that the boolean value returned from push is unused, already fixed it.
Regarding the non-trivilaity, the rustc is smart enough not to increase the size of the profiler and use the inner string reference non-nullability to store the discriminant.

@Veetaha
Copy link
Contributor Author

Veetaha commented Apr 28, 2020

@matklad, this one is easy, do we merge it?

@matklad
Copy link
Member

matklad commented Apr 28, 2020

bors r+

@lnicola
Copy link
Member

lnicola commented Apr 28, 2020

Might need a rebase.

@bors
Copy link
Contributor

bors bot commented Apr 28, 2020

@bors bors bot merged commit 9230ae5 into rust-lang:master Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants