-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Make Iterator::unzip fast #72159
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
Make Iterator::unzip fast #72159
Conversation
Closes rust-lang#72085 This consists of the following optimizations: * Adds a `with_capacity` function to `Extend`. This definitely needs more thought if it's going to be stabilized, so I'm not writing an RFC yet. This takes off most of the performance gap. * Optimizes `Vec`'s `Extend` implementation for the case where `size_hint` is 1. This shaves off the remaining performance gap.
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
FYI, I submitted my version in #72162. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@cuviper Your approach seems much cleaner, so I'll close this PR. |
Closes #72085
This consists of the following optimizations:
with_capacity
function toExtend
. This definitely needs more thought if it's going to be stabilized, so I'm not writing an RFC yet. This takes off most of the performance gap.Vec
'sExtend
implementation for the case wheresize_hint
is 1. This shaves off the remaining performance gap.Here's a fancy graph of the improvement:
