Skip to content
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

fix: Optimize nth implementation for legacy UnorderedMap #801

Merged
merged 2 commits into from
Apr 28, 2022

Conversation

austinabell
Copy link
Contributor

Made the change minimally invasive since this is somewhat of a legacy collection. The new ones are optimized and I assumed that zip with the optimization done to #634 would be applied to the UnorderedMap, but it wasn't.

exposes unordered_map module to allow Iter type to be used. Didn't add iterator types to others since no demand. There would be a benefit (in that the aux iterator traits would be available) but I don't want to return vector::Iter for backwards compatibility if we wanted to switch later and didn't want to just add a bunch of redundant code for no strong reason.

Copy link
Member

@ChaoticTempest ChaoticTempest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, so without this optimization, skip would've loaded in the elements twice over due to calling into nth twice and nth always loaded all the elements up to n? That's a pretty big win if someone were still using the old collections 👏

@austinabell
Copy link
Contributor Author

interesting, so without this optimization, skip would've loaded in the elements twice over due to calling into nth twice and nth always loaded all the elements up to n? That's a pretty big win if someone were still using the old collections 👏

Yeah, zip for some reason avoids calling nth on the inner iterator and just instead calls next n times

@austinabell austinabell merged commit cbff5e7 into master Apr 28, 2022
@austinabell austinabell deleted the austin/coll_optimize branch April 28, 2022 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants