Skip to content

Commit a5d48ad

Browse files
committed
Merge pull request #400 from dduan/hashed_collection_equality_by_address
compare Set and Dictionary by address for equality
2 parents 3e5ce67 + 9c28ff0 commit a5d48ad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,10 @@ public func == <Element : Hashable>(lhs: Set<Element>, rhs: Set<Element>) -> Boo
678678
case (.Native(let lhsNativeOwner), .Native(let rhsNativeOwner)):
679679
let lhsNative = lhsNativeOwner.nativeStorage
680680
let rhsNative = rhsNativeOwner.nativeStorage
681-
// FIXME(performance): early exit if lhs and rhs reference the same
682-
// storage?
681+
682+
if lhsNativeOwner === rhsNativeOwner {
683+
return true
684+
}
683685

684686
if lhsNative.count != rhsNative.count {
685687
return false
@@ -1184,8 +1186,10 @@ public func == <Key : Equatable, Value : Equatable>(
11841186
case (.Native(let lhsNativeOwner), .Native(let rhsNativeOwner)):
11851187
let lhsNative = lhsNativeOwner.nativeStorage
11861188
let rhsNative = rhsNativeOwner.nativeStorage
1187-
// FIXME(performance): early exit if lhs and rhs reference the same
1188-
// storage?
1189+
1190+
if lhsNativeOwner === rhsNativeOwner {
1191+
return true
1192+
}
11891193

11901194
if lhsNative.count != rhsNative.count {
11911195
return false

0 commit comments

Comments
 (0)