From 178b0215eb26c026f0d2e9aa559cb9d7f3fd4479 Mon Sep 17 00:00:00 2001 From: Brandon Williams <135203+mbrandonw@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:50:15 +1100 Subject: [PATCH] Short circuit == when ordered sets don't have same size. (#2556) --- .../xcshareddata/swiftpm/Package.resolved | 9 +++++---- .../Integration/Integration.xcodeproj/project.pbxproj | 4 ++-- .../Internal/AreOrderedSetsDuplicates.swift | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved index 832e5e2ce65e..0374cb958398 100644 --- a/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-concurrency-extras", "state" : { - "revision" : "6155400cb15b0d99b2c257d57603d61d03a817a8", - "version" : "1.0.1" + "revision" : "bb5059bde9022d69ac516803f4f227d8ac967f71", + "version" : "1.1.0" } }, { @@ -113,7 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-snapshot-testing.git", "state" : { - "revision" : "bbc9ec6e41ba964a5d04371af0acfb574cadafbd" + "revision" : "bb0ea08db8e73324fe6c3727f755ca41a23ff2f4", + "version" : "1.14.2" } }, { @@ -137,7 +138,7 @@ { "identity" : "swiftui-navigation", "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swiftui-navigation", + "location" : "https://github.com/pointfreeco/swiftui-navigation.git", "state" : { "revision" : "74adfb8e48724c50d0ac148c658ae5fa7dfd6b6d", "version" : "1.0.3" diff --git a/Examples/Integration/Integration.xcodeproj/project.pbxproj b/Examples/Integration/Integration.xcodeproj/project.pbxproj index 870f6f9b9981..a2359db4ff00 100644 --- a/Examples/Integration/Integration.xcodeproj/project.pbxproj +++ b/Examples/Integration/Integration.xcodeproj/project.pbxproj @@ -838,8 +838,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing.git"; requirement = { - kind = revision; - revision = bbc9ec6e41ba964a5d04371af0acfb574cadafbd; + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/Sources/ComposableArchitecture/Internal/AreOrderedSetsDuplicates.swift b/Sources/ComposableArchitecture/Internal/AreOrderedSetsDuplicates.swift index 872714145d98..fb5044187207 100644 --- a/Sources/ComposableArchitecture/Internal/AreOrderedSetsDuplicates.swift +++ b/Sources/ComposableArchitecture/Internal/AreOrderedSetsDuplicates.swift @@ -3,7 +3,10 @@ import OrderedCollections @inlinable func areOrderedSetsDuplicates(_ lhs: OrderedSet, _ rhs: OrderedSet) -> Bool { - withUnsafePointer(to: lhs) { lhsPointer in + guard lhs.count == rhs.count + else { return false } + + return withUnsafePointer(to: lhs) { lhsPointer in withUnsafePointer(to: rhs) { rhsPointer in memcmp(lhsPointer, rhsPointer, MemoryLayout>.size) == 0 || lhs == rhs }