diff --git a/stdlib/public/core/Set.swift b/stdlib/public/core/Set.swift index f4fb463fe24db..2567b656e0f74 100644 --- a/stdlib/public/core/Set.swift +++ b/stdlib/public/core/Set.swift @@ -1123,7 +1123,15 @@ extension Set { /// otherwise, `false`. @inlinable public func isDisjoint(with other: Set) -> Bool { - return _isDisjoint(with: other) + guard !isEmpty && !other.isEmpty else { return true } + let (smaller, larger) = + count < other.count ? (self, other) : (other, self) + for member in smaller { + if larger.contains(member) { + return false + } + } + return true } @inlinable