Skip to content

Commit 725ee55

Browse files
committed
[stdlib] Optimize Set.isSuperset<S>(of: S)
Call into the specialized overload if the argument happens to be a `Set`.
1 parent 9043c71 commit 725ee55

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
@@ -763,7 +763,10 @@ extension Set: SetAlgebra {
763763
/// otherwise, `false`.
764764
@inlinable
765765
public func isSuperset<S: Sequence>(of possibleSubset: __owned S) -> Bool
766-
where S.Element == Element {
766+
where S.Element == Element {
767+
if let s = possibleSubset as? Set<Element> {
768+
return isSuperset(of: s)
769+
}
767770
for member in possibleSubset {
768771
if !contains(member) {
769772
return false

0 commit comments

Comments
 (0)