Override StepBy::{try_fold, try_rfold}#64121
Override StepBy::{try_fold, try_rfold}#64121bors merged 1 commit intorust-lang:masterfrom timvermeulen:iter_step_by_internal
StepBy::{try_fold, try_rfold}#64121Conversation
|
r? @KodrAus (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @scottmcm |
scottmcm
left a comment
There was a problem hiding this comment.
Thanks for the PR! This definitely seems like one that needs try_fold (though I wish LLVM would just peel it). One minor change and it'll be good to go.
src/libcore/iter/adapters/mod.rs
Outdated
There was a problem hiding this comment.
Can you just use a while let Some(x) = self.iter.nth(self.step) loop here instead? It'll do the same thing, but without introducing a new closure that would regress #62429.
There was a problem hiding this comment.
Thanks, I forgot about that. I turned the closures into functions instead, that should have the same benefits, correct? I figured this will make it easier to potentially undo these changes in the future.
|
@bors r+ rollup |
|
📌 Commit 78908f2 has been approved by |
… r=scottmcm
Override `StepBy::{try_fold, try_rfold}`
Previous PR: rust-lang#51435
The previous PR was closed in favor of rust-lang#51601, which was later reverted. I don't think these implementations will make it harder to specialize `StepBy<Range<_>>` later, so we should be able to land this without any consequences.
This should fix rust-lang#57517 – in my benchmarks `iter` and `iter.step_by(1)` now perform equally well, provided internal iteration is used.
Previous PR: #51435
The previous PR was closed in favor of #51601, which was later reverted. I don't think these implementations will make it harder to specialize
StepBy<Range<_>>later, so we should be able to land this without any consequences.This should fix #57517 – in my benchmarks
iteranditer.step_by(1)now perform equally well, provided internal iteration is used.