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:
Chris Lattner
2015-12-15 23:18:55 -08:00
parent 46aef83345
commit e9a2e1e128
15 changed files with 73 additions and 36 deletions

View File

@@ -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))