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.
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
[Foundation] Modernize hashing in Foundation's Swift-only types #23832
[Foundation] Modernize hashing in Foundation's Swift-only types #23832
Changes from all commits
668c1f068e644946225d7569e38073ad83081567ed0867f7e8b7adb3741122a73be6b8c1049e7a0004229c468582d5520e5e451e64bdc458afa2539b41eb9710cb05a590f40723cc719a23c3f328e46886f40a4ab711ed9f859dd12ab24317f1dd3e582b65b13bc5676647c50530687fFile filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Note: There is no need to emulate NSDate's hashing behavior, or the behavior of any previous version of
Date.hashValue. Swift is very explicit that the values returned byhashValuearen't to be treated as stable, and Swift trains programmers to expect randomized hashes.Granted, in this case (like with many other hashValues removed by this PR), 5.0 did not vend properly seeded hashes, so in theory someone could be relying on the exact values returned. I believe this is still a low-risk change; and since this is not inlinable code, we have the option to re-add specific
hashValueimplementations with an SDK check if it turns some of them have ABI impact.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.
Using the
enddate here was problematic, since==comparesstartandduration, notstartandend.enddoes not always include all the information that's present induration, so doing this results in weaker hashes.The new code is careful to match the implementation of
==.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.
The original implementation of
Measurement.hashValueis not a valid hash, because it is in conflict with==.(A version of this change was originally submitted as #20879.)