-
Notifications
You must be signed in to change notification settings - Fork 289
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
Add shortcircuit in iteration if we yielded all elements #338
Conversation
I do have some concerns:
|
OK, I would fix improve my PR tomorrow. |
@Amanieu I have a question about this lines: What this comment means and what should be here in version without end pointer check? |
You should leave this code and comment as it is. The only change needed is removing the check against |
Updated. I decided to remove check using constant flag, compiler should remove checks during compilation. |
Current implementation works little slower than `set.iter().take(set.len())`. See my comment [here](rust-lang/rust#97215 (comment)). So why not avoid extra integer which added by `Iterator::take` if we can add limiting logic into our iterator itself? Also, removed end pointer check if we can limit iteration by counting items yielded.
Nice work! Have you tried running the benchmarks to compare performance before/after? |
I forgot :D Reminder: this is the bench for almost empty hash sets.
|
@bors r+ |
📌 Commit ea120c7 has been approved by |
☀️ Test successful - checks-actions |
Current implementation works little slower than
set.iter().take(set.len())
.See my comment here.
So why not avoid extra integer which added by
Iterator::take
if we can add limiting logic into our iterator itself?I don't really know how this change affects reflect_toogle_full and implementation of FusedIterator. Maybe I should make inner iterator "jump" to the end of its memory block?