-
Notifications
You must be signed in to change notification settings - Fork 641
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
SWEEP: Add unchecked to GetHashCode, #1065 #1068
Conversation
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.
Thanks for the PR. It looks good.
There are 3 places where we are now doubling up on the unchecked
block with an unchecked cast in the middle. We can now remove the cast. See the inline comments.
Wouldn't this be categorized as a performance improvement rather than a bugfix? |
I'm not sure there would be any performance impact. Originally I had assumed that we needed to do this to avoid overflow exceptions, but I realized just now that our projects do not have the "Check for arithmetic overflow" compiler option checked, so that reasoning is not valid alone. Perhaps an argument could be made that it helps ensure best practices and might help users if they want to recompile the library with that option for some reason, as well as to be consistent with other places in the codebase where we were already using |
Aside: we seem to be more regularly be getting transient build failures downloading from nuget.org and MyGet again. This possibly is a result of adding the .NET 9 tests with an extra ~70 actions running in parallel. Fortunately the workaround is simple, to just choose the option to re-run failed jobs. |
I suspect this is due to extra holiday traffic, however, it would probably help if we enabled NuGet caching (#856 and #857). I am not convinced we need to generate an extra file and figure out how to maintain it just so we can update packages, though. Our first attempt at doing so (on Azure DevOps) didn't need to, but the key didn't include the |
Adds
unchecked
to all GetHashCode implementations where it is applicableFixes #1065
Description
GetHashCode should not throw an exception on overflow. This PR adds
unchecked
blocks to all GetHashCode implementations that do addition or multiplication that could overflow.During review, it was determined that GetHashCode methods that return constants, simply delegate GetHashCode to another object, or solely do bitwise xor operations do not need
unchecked
added.