mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Eliminate all of the uses of ++/-- from stdlib/public/core.
At DaveA's suggestion, I took a mostly mechanical approach to this: pointers and numeric types start using += 1, and indexes use i = i.successor(). The index model is likely to be revised in Swift 3 anyway, so micro-optimizing this code syntactically isn't super important. There is some performance concern of this patch, since some in-place succesor operations are more efficient than i = i.successor(). The one that seems particularly at issue is the instance in the implementation of partition(), which I changed to use i._successorInPlace(). If other instances lead to a perf issue, they can be changed to use that as well.
This commit is contained in:
@@ -713,7 +713,7 @@ public func == <Element : Hashable>(lhs: Set<Element>, rhs: Set<Element>) -> Boo
|
||||
}
|
||||
|
||||
let endIndex = lhsNative.endIndex
|
||||
for var i = lhsNative.startIndex; i != endIndex; ++i {
|
||||
for var i = lhsNative.startIndex; i != endIndex; i = i.successor() {
|
||||
let key = lhsNative.assertingGet(i)
|
||||
let bridgedKey: AnyObject = _bridgeToObjectiveCUnconditional(key)
|
||||
let optRhsValue: AnyObject? = rhsCocoa.maybeGet(bridgedKey)
|
||||
@@ -1230,7 +1230,8 @@ public func == <Key : Equatable, Value : Equatable>(
|
||||
}
|
||||
|
||||
let endIndex = lhsNative.endIndex
|
||||
for var index = lhsNative.startIndex; index != endIndex; ++index {
|
||||
for var index = lhsNative.startIndex; index != endIndex;
|
||||
index = index.successor() {
|
||||
let (key, value) = lhsNative.assertingGet(index)
|
||||
let optRhsValue: AnyObject? =
|
||||
rhsCocoa.maybeGet(_bridgeToObjectiveCUnconditional(key))
|
||||
|
||||
Reference in New Issue
Block a user