Skip to content

Is hashcode comparison necessary in DefaultFrozenDictionary GetValueRefOrNullRefCore? #107878

Closed Answered by stephentoub
Artromskiy asked this question in Q&A
Discussion options

You must be logged in to vote

While the implementation tries to reduce the number of collisions when mapping hash tables to buckets, it doesn't guarantee a 1:1 ratio. As such, the same bucket can contain entries with different hash codes. And as it's generally much cheaper to compare an int than to do the equality comparison for a key, eliminating the hash code can show up as a regression. It's there to prevent that.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Artromskiy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area-System.Collections tenet-performance Performance related issue untriaged New issue has not been triaged by the area owner
2 participants
Converted from issue

This discussion was converted from issue #107866 on September 16, 2024 17:07.