-
Couldn't load subscription status.
- Fork 10.6k
[SE-0494][StdLib] Add isTriviallyIdentical(to:) Methods to Dictionary and Set
#82439
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
base: main
Are you sure you want to change the base?
Conversation
18f927e to
9d866eb
Compare
e395baa to
99ad169
Compare
|
@swift-ci please Apple silicon benchmark |
adbdeb8 to
e73320c
Compare
e73320c to
390f0c7
Compare
isIdentical Methods for Quick Comparisons to Dictionary and SetisTriviallyIdentical(to:) Methods for Quick Comparisons to Dictionary and Set
390f0c7 to
20061b0
Compare
| /// considered identical. | ||
| /// | ||
| /// - Performance: O(1) | ||
| @_alwaysEmitIntoClient |
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.
@lorentey Opaque here?
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.
This type is generic, so sadly the answer is no -- we need this to be at least @inlinable. @_aeic is fine.
|
@swift-ci please Apple silicon benchmark |
|
@swift-ci Please smoke test |
isTriviallyIdentical(to:) Methods for Quick Comparisons to Dictionary and SetisTriviallyIdentical(to:) Methods to Dictionary and Set
|
@swift-ci Please smoke test Windows platform |
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test |
Background
SE-0494
We propose new
isTriviallyIdentical(to:)instance methods to the following concrete types for determining in constant-time if two instances must be equal by-value:Instead of “one big diff”… we can try and keep the diffs grouped together by similar functionality:
Changes
Our
Dictionarydoes not directly perform a fast path for equality checking in our==operator.1 We can actually steal an idea fromDictionary.Keys.2 If both variants are native, we compare the storage buffer directly. If both variants are Cocoa, we compare the objects directly.Our
Setperforms a similar check over variants for our==operator.3 We can check identity similar toDictionary:Test Plan
New tests were added for
DictionaryandSet.Benchmarks
New benchmarks were added for
DictionaryandSet.Footnotes
https://github.com/swiftlang/swift/blob/swift-6.1.2-RELEASE/stdlib/public/core/Dictionary.swift#L1583-L1598 ↩
https://github.com/swiftlang/swift/blob/swift-6.1.2-RELEASE/stdlib/public/core/Dictionary.swift#L1365-L1384 ↩
https://github.com/swiftlang/swift/blob/swift-6.1.2-RELEASE/stdlib/public/core/Set.swift#L408-L424 ↩