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
Conversation
Force-pushed due to some rustup connection problem on CI: |
crates/ra_prof/src/hprof.rs
Outdated
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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@matklad, this one is easy, do we merge it? |
bors r+ |
Might need a rebase. |
Build succeeded: |
No description provided.