Skip to content

Commit 8612f2f

Browse files
committed
[stdlib] Add a fast path to Set.isDisjoint<S>(with: S)
Have the generic variant call out to the specialized overload if the argument happens to be a `Set`.
1 parent a2540c2 commit 8612f2f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/public/core/Set.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,9 @@ extension Set: SetAlgebra {
820820
@inlinable
821821
public func isDisjoint<S: Sequence>(with other: S) -> Bool
822822
where S.Element == Element {
823+
if let s = other as? Set<Element> {
824+
return isDisjoint(with: s)
825+
}
823826
return _isDisjoint(with: other)
824827
}
825828

@@ -1142,7 +1145,7 @@ extension Set {
11421145
}
11431146
return true
11441147
}
1145-
1148+
11461149
@inlinable
11471150
internal func _isDisjoint<S: Sequence>(with other: S) -> Bool
11481151
where S.Element == Element {

0 commit comments

Comments
 (0)