[OrderedDictionary] forward ordered dictionary values equality to values property#335
[OrderedDictionary] forward ordered dictionary values equality to values property#335lorentey merged 5 commits intoapple:release/1.0from vanvoorden:vanvoorden/ordered-dictionary-values-equality
Conversation
|
@swift-ci test |
|
@ingoem thanks for suggesting the reference equality check! |
Tests/_CollectionsTestSupport/AssertionContexts/Assertions.swift
Outdated
Show resolved
Hide resolved
|
@vanvoorden Can you please rebase this PR on top of the I think it would make sense to ship this in the next patch release, rather than having it linger on main indefinitely. |
@lorentey Sounds good. Thanks! |
|
@lorentey Is there a CI job that can run |
Here are benchmarks running locally. The reason that |
lorentey
left a comment
There was a problem hiding this comment.
Thanks for rebasing. Nice work on the benchmarks! 👍
Reviewing #340 made me realize what's been bothering me about expectNotEqualElements; I added new recommendations to remove it and the test that exercises it. (Please see the notes below.)
Tests/OrderedCollectionsTests/OrderedDictionary/OrderedDictionary+Values Tests.swift
Outdated
Show resolved
Hide resolved
Sources/_CollectionsTestSupport/AssertionContexts/Assertions.swift
Outdated
Show resolved
Hide resolved
Tests/OrderedCollectionsTests/OrderedDictionary/OrderedDictionary+Values Tests.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
|
@lorentey Thanks for reviewing! |
|
@swift-ci test |
|
(AFAIK, CI runs are still expected to fail on macOS. This is "fine", and it won't block us from landing this.) |
…v1.0.6 (#822) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [com_github_apple_swift_collections](https://togithub.com/apple/swift-collections) | http_archive | patch | `1.0.5` -> `1.0.6` | --- ### Release Notes <details> <summary>apple/swift-collections (com_github_apple_swift_collections)</summary> ### [`v1.0.6`](https://togithub.com/apple/swift-collections/releases/tag/1.0.6): Swift Collections 1.0.6 [Compare Source](https://togithub.com/apple/swift-collections/compare/1.0.5...1.0.6) This bugfix release adds `Sendable` conformances to all public types (fixing compatibility with Swift's strict concurrency checking), and speeds up equality checks (`==`) of identical collection values. ##### What's Changed - Fix typos: OrderedSet Documentation by [@​kati-kms](https://togithub.com/kati-kms) in [https://github.com/apple/swift-collections/pull/322](https://togithub.com/apple/swift-collections/pull/322) - \[1.0] build: support building in Debug mode on Windows by [@​compnerd](https://togithub.com/compnerd) in [https://github.com/apple/swift-collections/pull/337](https://togithub.com/apple/swift-collections/pull/337) - build: tweak search path for embedding by [@​compnerd](https://togithub.com/compnerd) in [https://github.com/apple/swift-collections/pull/338](https://togithub.com/apple/swift-collections/pull/338) - \[OrderedDictionary] forward ordered dictionary values equality to values property by [@​vanvoorden](https://togithub.com/vanvoorden) in [https://github.com/apple/swift-collections/pull/335](https://togithub.com/apple/swift-collections/pull/335) - \[OrderedSet] forward ordered set equality to elements property by [@​vanvoorden](https://togithub.com/vanvoorden) in [https://github.com/apple/swift-collections/pull/340](https://togithub.com/apple/swift-collections/pull/340) - \[Deque] check deque equality with buffer identity by [@​vanvoorden](https://togithub.com/vanvoorden) in [https://github.com/apple/swift-collections/pull/341](https://togithub.com/apple/swift-collections/pull/341) - \[OrderedDictionary] Fix usage of deprecated API in index(forKey:) docs by [@​lorentey](https://togithub.com/lorentey) in [https://github.com/apple/swift-collections/pull/342](https://togithub.com/apple/swift-collections/pull/342) - \[1.0] Backport Sendable conformances on all public types by [@​lorentey](https://togithub.com/lorentey) in [https://github.com/apple/swift-collections/pull/343](https://togithub.com/apple/swift-collections/pull/343) - OrderedSet: Fix sendable conformance on old swifts by [@​lorentey](https://togithub.com/lorentey) in [https://github.com/apple/swift-collections/pull/346](https://togithub.com/apple/swift-collections/pull/346) - Update CMake configuration by [@​lorentey](https://togithub.com/lorentey) in [https://github.com/apple/swift-collections/pull/347](https://togithub.com/apple/swift-collections/pull/347) ##### New Contributors - [@​kati-kms](https://togithub.com/kati-kms) made their first contribution in [https://github.com/apple/swift-collections/pull/322](https://togithub.com/apple/swift-collections/pull/322) - [@​vanvoorden](https://togithub.com/vanvoorden) made their first contribution in [https://github.com/apple/swift-collections/pull/335](https://togithub.com/apple/swift-collections/pull/335) **Full Changelog**: apple/swift-collections@1.0.5...1.0.6 Thank you to everyone who contributed to this release! </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDAuMCIsInVwZGF0ZWRJblZlciI6IjM2LjEwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>


Background
#334
The current implementation of
OrderedDictionary.Values.==forwards toSequence.elementsEqual, which needs to perform a linear-time (O[N]) comparison over both collections.[1]Since the "backing store" of our
OrderedDictionary.Valuesis aContiguousArray, we can forward that equality check through toContiguousArray. If bothValuesinstances point to the same identity, theContiguousArrayimplementation will return early from the comparison.[2]We perform a similar check (against the
ContiguousArray) in our implementation ofOrderedDictionary.==.[3][1] https://github.com/apple/swift/blob/main/stdlib/public/core/SequenceAlgorithms.swift#L319-L336
[2] https://github.com/apple/swift/blob/main/stdlib/public/core/ContiguousArray.swift#L1318-L1321
[3] https://github.com/apple/swift-collections/blob/main/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary%2BEquatable.swift#L20-L22
Changes
We migrate from:
We migrate to:
Test Plan
Two new tests are added:
OrderedDictionaryValueTests.test_values_getter_equalOrderedDictionaryValueTests.test_values_getter_not_equalChecklist