Add shortcircuit in iteration if we yielded all elements#338
Add shortcircuit in iteration if we yielded all elements#338bors merged 1 commit intorust-lang:masterfrom AngelicosPhosphoros:master
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::takeif 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?