[Merged by Bors] - Optimize Iterator::count for event iterators - #7582
[Merged by Bors] - Optimize Iterator::count for event iterators#7582joseph-gio wants to merge 1 commit into
Iterator::count for event iterators#7582Conversation
|
Those iterators also implement |
What do you mean by this? |
|
the doc for the trait methods is https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.count which specifically mention calling all the |
|
Correct me if I'm wrong, but there is no observable difference between repeatedly calling |
You're right. Let's hope no one rely on something being not the most efficient 😄 |
# Objective Related to #7530. `EventReader` iterators currently use the default impl for `.count()`, which unnecessarily loops over all unread events. # Solution Add specialized impls that mark the `EventReader` as consumed and return the number of unread events.
|
Pull request successfully merged into main. Build succeeded:
|
Iterator::count for event iteratorsIterator::count for event iterators
# Objective Related to bevyengine#7530. `EventReader` iterators currently use the default impl for `.count()`, which unnecessarily loops over all unread events. # Solution Add specialized impls that mark the `EventReader` as consumed and return the number of unread events.
# Objective Related to bevyengine#7530. `EventReader` iterators currently use the default impl for `.count()`, which unnecessarily loops over all unread events. # Solution Add specialized impls that mark the `EventReader` as consumed and return the number of unread events.
Objective
Related to #7530.
EventReaderiterators currently use the default impl for.count(), which unnecessarily loops over all unread events.Solution
Add specialized impls that mark the
EventReaderas consumed and return the number of unread events.