Conversation
Morriar
approved these changes
Sep 2, 2025
| } | ||
|
|
||
| impl Hasher for IdentityHasher { | ||
| fn write(&mut self, _bytes: &[u8]) {} |
Contributor
There was a problem hiding this comment.
Should we do something like this?
Suggested change
| fn write(&mut self, _bytes: &[u8]) {} | |
| fn write(&mut self, _bytes: &[u8]) { | |
| unreachable!("IdentityHasher#write should never be called"); | |
| } |
Contributor
There was a problem hiding this comment.
Should we also disable all the other variants? http://doc.rust-lang.org/beta/std/hash/trait.Hasher.html#provided-methods
| } | ||
|
|
||
| pub type IdentityHashMap<K, V> = HashMap<K, V, IdentityHashBuilder>; | ||
| pub type IdentityHashSet<K> = HashSet<K, IdentityHashBuilder>; |
Contributor
There was a problem hiding this comment.
Suggested change
| pub type IdentityHashSet<K> = HashSet<K, IdentityHashBuilder>; | |
| pub type IdentityHashSet<T> = HashSet<T, IdentityHashBuilder>; |
Contributor
There was a problem hiding this comment.
Any way we can add tests for this?
Member
Author
Merge activity
|
Contributor
|
Was this auto-merged? 🤔 |
Member
Author
|
Yes, my bad I had auto merge turned on. I'll address the comments. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR creates
IdentityHashMapandIdentityHashSetimplementations. These are identical to a regularHashMaporHashSet, with the sole difference that it does not try to hash any of the inserted values as they have already been hashed externally by our IDs.This improves performance by quite a bit as we avoid a lot of duplicate work.