-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
C#: Use HashCode.Combine()
for basic composite types instead of xor
#82240
Conversation
This differs from all the other vectors, and all other types in fact If this is to be done it needs to be done completely |
This is not all cases either, you're missing |
HashCode.Combine
instead of xor for GetHashCode()
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.
LGTM
HashCode.Combine
instead of xor for GetHashCode()
HashCode.Combine()
for basic composite types instead of xor
For the record, your commit seems not to be linked to your GitHub account. See: Why are my commits linked to the wrong user? for more info. |
Thanks! And congrats for your first merged Godot contribution 🎉 Remember to add the email used for this commit as secondary email in your GitHub profile, if you want to claim this commit as authored by your GitHub account. Otherwise your next PR will still show as "First-time contributor". |
HashCode.Combine()
for basic composite types instead of xorHashCode.Combine()
for basic composite types instead of xor
Vector2I.GetHashCode() creates hash conflicts if X and Y concide:
(0, 0) => 0.GetHashCode() ^ 0.GetHashCode() == 0
(1, 1) => 1.GetHashCode() ^ 1.GetHashCode() == 0
(2, 2) => 2.GetHashCode() ^ 2.GetHashCode() == 0
Let's use
HashCode.Combine(X, Y)
instead. It will combine hash codes properly and minimize conflicts.