-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Optimise Chars::last() #37882
Optimise Chars::last() #37882
Conversation
The default implementation of last() goes through the entire iterator but that's not needed here.
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup Thank you! |
📌 Commit de2f617 has been approved by |
By the way, this applies to char_indices as well. Another commit or another PR is welcome. |
The default implementation of last() goes through the entire iterator but that's not needed here.
Good point. I've applied the same to |
@bors r+ rollup |
📌 Commit 9e86e18 has been approved by |
Optimise Chars::last() The default implementation of last() goes through the entire iterator but that's not needed here.
Shouldn't this apply to any |
Yeah, but I think it might be breaking change to do this for iterators that might have side effects. |
Yes. Iterator::last's doc is specific about how it goes about finding the last value (traversing it all). |
The default implementation of last() goes through the entire iterator
but that's not needed here.