Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
tracing: ensmallerate assembly generated by macro expansions #943
tracing: ensmallerate assembly generated by macro expansions #943
Changes from 4 commits
f810039
540a158
182d1b4
1d31fe1
283dcb9
4a52a12
ec43888
9d458e2
248c7d2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Adding this was necessary since constructing the
ValueSet
in a closure means we needed aFnOnce
so that values can be moved into the closure (which happens primarily when users wrap values infield::display
/field::debug
without borrowing). Not supporting this would break at least some code. I opted to add a new function that takes aFnOnce
, rather than capturing anOption<FnOnce>
into theFnMut
andtake
ing it, because that seemed significantly less efficient.We could probably commit to making this a public API (and even deprecate
get_default
, the version that takes aFnMut
). This is probably a more useful API thanget_default
taking aFnMut
... I didn't make it public here, though, because introducing a new public API seemed like a job for another PR.Also, in 0.2, the
Value
changes will makeValue::debug
andValue::display
also borrow rather than move. So, theFnOnce
will no longer be necessary, and we could, alternatively, remove this function in 0.2, rather than deprecating the existingget_current
.So, there should probably be an actual design discussion... :)
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.
Is it actually worse here to call the inlined interest fn here?
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.
It would be fine for it to be inlined into this function, since this function shouldn't be inlined. The reason it doesn't is that the
interest
function callsregister
(this function) if the cached value is not 0, 1, or 2. That means that if we register the callsite and the cached interest value is still not one of those, we could recurse again, potentially infinitely.This shouldn't happen ever, but if there's a bug elsewhere, I'd rather just assume the cached value is invalid and return
Interest::sometimes()
(which is what this method does), rather than overflowing the stack.