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

Deduplicate Pusher::try_{reserve,push} #13

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

mattfbacon
Copy link
Contributor

No description provided.

@cbiffle
Copy link
Owner

cbiffle commented Mar 2, 2024

So, this seems like a sufficiently obvious win that I'm sitting here staring at the code, trying to figure out why I didn't do this to begin with. (That's intended as a compliment.)

TBH I was probably just in a hurry, since the cancel-correctness changes happened during the frantic lead-up to finishing my sculpture in the summer. Assuming I don't notice some subtle reason for the duplication, I'm planning on merging this.

entry.push(value);
Ok(())
} else {
Err(value)
Copy link
Owner

Choose a reason for hiding this comment

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

I felt like I ought to be able to rewrite this to use Option::ok_or_else, but it just doesn't work because it'd move T. So I think this is probably the most concise way of expressing it already.

@cbiffle
Copy link
Owner

cbiffle commented Mar 2, 2024

So, rebased this and did some testing with my firmware projects. The generated code is, while not exactly identical to before, definitely the same size, which is lovely -- sometimes the inlining heuristics do weird things for changes like this.

I can't think of a reason not to do this. Thanks for the cleanup!

@cbiffle cbiffle merged commit b36b61f into cbiffle:main Mar 2, 2024
4 checks passed
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.

2 participants