File tree Expand file tree Collapse file tree 1 file changed +7
-21
lines changed Expand file tree Collapse file tree 1 file changed +7
-21
lines changed Original file line number Diff line number Diff line change @@ -391,25 +391,6 @@ extension Set: Collection {
391
391
}
392
392
}
393
393
394
- /// Check for both subset and equality relationship between
395
- /// a set and some sequence (which may itself be a `Set`).
396
- ///
397
- /// (isSubset: lhs ⊂ rhs, isEqual: lhs ⊂ rhs and |lhs| = |rhs|)
398
- @inlinable
399
- internal func _compareSets< Element> (
400
- _ lhs: Set < Element > ,
401
- _ rhs: Set < Element >
402
- ) -> ( isSubset: Bool , isEqual: Bool ) {
403
- // FIXME(performance): performance could be better if we start by comparing
404
- // counts.
405
- for member in lhs {
406
- if !rhs. contains ( member) {
407
- return ( false , false )
408
- }
409
- }
410
- return ( true , lhs. count == rhs. count)
411
- }
412
-
413
394
// FIXME: rdar://problem/23549059 (Optimize == for Set)
414
395
// Look into initially trying to compare the two sets by directly comparing the
415
396
// contents of both buffers in order. If they happen to have the exact same
@@ -1316,8 +1297,13 @@ extension Set {
1316
1297
/// - Returns: `true` if the set is a subset of `other`; otherwise, `false`.
1317
1298
@inlinable
1318
1299
public func isSubset( of other: Set < Element > ) -> Bool {
1319
- let ( isSubset, isEqual) = _compareSets ( self , other)
1320
- return isSubset || isEqual
1300
+ guard self . count <= other. count else { return false }
1301
+ for member in self {
1302
+ if !other. contains ( member) {
1303
+ return false
1304
+ }
1305
+ }
1306
+ return true
1321
1307
}
1322
1308
1323
1309
/// Returns a Boolean value that indicates whether this set is a superset of
You can’t perform that action at this time.
0 commit comments