-
-
Notifications
You must be signed in to change notification settings - Fork 722
feat(allocator): add HashMap::from_iter_in
#14211
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
feat(allocator): add HashMap::from_iter_in
#14211
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #14211 will not alter performanceComparing Summary
|
overlookmotel
left a comment
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.
I think it's good to add this method. It's a basic functionality, and weird we didn't have it already.
One thing: hashbrown::HashMap uses the lower bound of the size hint:
Whereas your impl here uses the upper bound.
I don't know which is best - it depends on the iterator! Upper bound could be a large over-estimate in the case of a filter iterator.
Unless you have some reason to think upper bound is better in our use cases, I would tend to copy hashbrown. It's the underlying implementation of Rust std lib's HashMap, so I'd assume there's some rationale for how it is.
6065c44 to
1767176
Compare
|
I didn't have any reason to use the upper bound. Sorry, I had not taken a look at the code after it was generated by AI. I've now taken a look and aligned the implementation with hashbrown. |
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.
Pull Request Overview
Adds a constructor to create an arena-allocated HashMap from an iterator.
- Introduces HashMap::from_iter_in to build a map using a provided allocator
- Documents the new API
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
overlookmotel
left a comment
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.
I'll follow up with a PR to add some comments.
Merge activity
|
This PR adds `HashMap::from_iter_in` to the arena allocated HashMap.
95be81c to
7a1c339
Compare
) Follow-on after #14211. Add comments reflecting conversation we had on that PR.

This PR adds
HashMap::from_iter_into the arena allocated HashMap.