We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents be98f6b + 00cb1c5 commit 50a1817Copy full SHA for 50a1817
stdlib/public/core/Set.swift
@@ -1123,7 +1123,15 @@ extension Set {
1123
/// otherwise, `false`.
1124
@inlinable
1125
public func isDisjoint(with other: Set<Element>) -> Bool {
1126
- return _isDisjoint(with: other)
+ guard !isEmpty && !other.isEmpty else { return true }
1127
+ let (smaller, larger) =
1128
+ count < other.count ? (self, other) : (other, self)
1129
+ for member in smaller {
1130
+ if larger.contains(member) {
1131
+ return false
1132
+ }
1133
1134
+ return true
1135
}
1136
1137
0 commit comments