@@ -713,15 +713,18 @@ public func == <Element : Hashable>(lhs: Set<Element>, rhs: Set<Element>) -> Boo
713
713
}
714
714
715
715
let endIndex = lhsNative.endIndex
716
- for var i = lhsNative.startIndex; i != endIndex; i = i.successor() {
716
+ var i = lhsNative.startIndex
717
+ while i != endIndex {
717
718
let key = lhsNative.assertingGet(i)
718
719
let bridgedKey: AnyObject = _bridgeToObjectiveCUnconditional(key)
719
720
let optRhsValue: AnyObject? = rhsCocoa.maybeGet(bridgedKey)
720
721
if let rhsValue = optRhsValue {
721
722
if key == _forceBridgeFromObjectiveC(rhsValue, Element.self) {
723
+ i = i.successor()
722
724
continue
723
725
}
724
726
}
727
+ i = i.successor()
725
728
return false
726
729
}
727
730
return true
@@ -1230,16 +1233,18 @@ public func == <Key : Equatable, Value : Equatable>(
1230
1233
}
1231
1234
1232
1235
let endIndex = lhsNative.endIndex
1233
- for var index = lhsNative.startIndex; index != endIndex;
1234
- index._successorInPlace() {
1236
+ var index = lhsNative.startIndex
1237
+ while index != endIndex {
1235
1238
let (key, value) = lhsNative.assertingGet(index)
1236
1239
let optRhsValue: AnyObject? =
1237
1240
rhsCocoa.maybeGet(_bridgeToObjectiveCUnconditional(key))
1238
1241
if let rhsValue = optRhsValue {
1239
1242
if value == _forceBridgeFromObjectiveC(rhsValue, Value.self) {
1243
+ index._successorInPlace()
1240
1244
continue
1241
1245
}
1242
1246
}
1247
+ index._successorInPlace()
1243
1248
return false
1244
1249
}
1245
1250
return true
@@ -2113,7 +2118,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
2113
2118
var description: String {
2114
2119
var result = ""
2115
2120
#if INTERNAL_CHECKS_ENABLED
2116
- for var i = 0; i != capacity; i += 1 {
2121
+ for i in 0..< capacity {
2117
2122
if isInitializedEntry(i) {
2118
2123
let key = keyAt(i)
2119
2124
result += "bucket \(i), ideal bucket = \(_bucket(key)), key = \(key)\n"
@@ -2601,7 +2606,7 @@ final internal class _Native${Self}StorageOwner<${TypeParametersDecl}>
2601
2606
let bridged = _createBridgedNativeStorage(nativeStorage.capacity)
2602
2607
2603
2608
// Bridge everything.
2604
- for var i = 0; i < nativeStorage.capacity; i += 1 {
2609
+ for i in 0..< nativeStorage.capacity {
2605
2610
if nativeStorage.isInitializedEntry(i) {
2606
2611
let key = _bridgeToObjectiveCUnconditional(nativeStorage.keyAt(i))
2607
2612
%if Self == 'Set':
@@ -3248,19 +3253,19 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
3248
3253
3249
3254
// Find the last bucket in the contiguous chain
3250
3255
var lastInChain = hole
3251
- for var b = nativeStorage._next(lastInChain);
3252
- nativeStorage.isInitializedEntry(b);
3253
- b = nativeStorage._next(b) {
3256
+ var b = nativeStorage._next(lastInChain)
3257
+ while nativeStorage.isInitializedEntry(b) {
3254
3258
lastInChain = b
3259
+ b = nativeStorage._next(b)
3255
3260
}
3256
3261
3257
3262
// Relocate out-of-place elements in the chain, repeating until
3258
3263
// none are found.
3259
3264
while hole != lastInChain {
3260
3265
// Walk backwards from the end of the chain looking for
3261
3266
// something out-of-place.
3262
- var b: Int
3263
- for b = lastInChain; b != hole; b = nativeStorage._prev(b) {
3267
+ var b = lastInChain
3268
+ while b != hole {
3264
3269
let idealBucket = nativeStorage._bucket(nativeStorage.keyAt(b))
3265
3270
3266
3271
// Does this element belong between start and hole? We need
@@ -3271,6 +3276,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
3271
3276
if start <= hole ? (c0 && c1) : (c0 || c1) {
3272
3277
break // Found it
3273
3278
}
3279
+ b = nativeStorage._prev(b)
3274
3280
}
3275
3281
3276
3282
if b == hole { // No out-of-place elements found; we're done adjusting
@@ -3409,7 +3415,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
3409
3415
nativeStorage = native
3410
3416
}
3411
3417
3412
- for var b = 0; b != nativeStorage.capacity; b += 1 {
3418
+ for b in 0..< nativeStorage.capacity {
3413
3419
if nativeStorage.isInitializedEntry(b) {
3414
3420
nativeStorage.destroyEntryAt(b)
3415
3421
}
0 commit comments