-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Optimize Iterator::count
for event iterators
#7582
Conversation
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 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging as trivial now that we've discussed it.
bors r+
# 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.
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.