-
Notifications
You must be signed in to change notification settings - Fork 291
Use record struct in FileHeaderOffset #1161
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
Conversation
| obj is FileHeaderOffset other && value == other.Value; | ||
|
|
||
| public override int GetHashCode() => value.GetHashCode(); | ||
| public override int GetHashCode() => Value.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.
Don't record structs provide these default implementations already?
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.
Yes, including the IEquatable implementation. See .NET Lab
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.
They do, but with default implementation. It's seems to be more efficient for speed to provide it when possible. Ill provide the source of that shortly
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.
not implementing these means it's going to use the EqualityComparer<int>.Default
In this specific case (single int in the struct), it's unsure if it's an actual improvement (might be an overkill).
See here for different benchmarks on record struct https://nietras.com/2021/06/14/csharp-10-record-struct/
No description provided.