-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
replace if
with match
in binary_search
#106969
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cuviper (or someone else) soon. Please see the contribution instructions for more information. |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
It looks like they lined up starting with Rust 1.65, which is when we upgraded to LLVM 15. However, in the few benchmarks we have, there's a measurable regression here. Here's the merge-base commit 4781233,
With your change:
The benchmarks are pretty small, but these results are very consistent across multiple runs. (I'm running |
FWIW, getting I've got two related LLVM bugs open (llvm/llvm-project#59666 & llvm/llvm-project#60012), #105840 is trying to make Thus without a strong argument that the |
Now, the
match
version generates pretty much the same assembly as theif
version. And I thinkmatch
is more readable thanif
. Here is the code: https://rust.godbolt.org/z/4vPc54hb7