Skip to content

Commit ccadbf3

Browse files
committed
Merge pull request #154 from nRewik/master
Remove ++ and -- operators
2 parents 8bcd59c + 14cc88d commit ccadbf3

File tree

8 files changed

+39
-27
lines changed

8 files changed

+39
-27
lines changed

Foundation/NSArray.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ public class NSMutableArray : NSArray {
710710

711711
var objectIdx = 0
712712
indexes.enumerateIndexesUsingBlock() { (insertionIndex, _) in
713-
self.insertObject(objects[objectIdx++], atIndex: insertionIndex)
713+
self.insertObject(objects[objectIdx], atIndex: insertionIndex)
714+
objectIdx += 1
714715
}
715716
}
716717

Foundation/NSCFDictionary.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ internal final class _NSCFDictionary : NSMutableDictionary {
5454
if index == count {
5555
return nil
5656
} else {
57-
return keyArray[index++]
57+
let item = keyArray[index]
58+
index += 1
59+
return item
5860
}
5961
}
6062

@@ -139,7 +141,7 @@ internal func _CFSwiftDictionaryGetKeysAndValues(dictionary: AnyObject, keybuf:
139141
(dictionary as! NSDictionary).enumerateKeysAndObjectsUsingBlock { key, value, _ in
140142
keybuf[idx] = Unmanaged<AnyObject>.passUnretained(key)
141143
valuebuf[idx] = Unmanaged<AnyObject>.passUnretained(value)
142-
idx++
144+
idx += 1
143145
}
144146
}
145147

Foundation/NSCalendar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
411411
private func _setComp(unitFlags: NSCalendarUnit, field: NSCalendarUnit, vector: [Int32], inout compIndex: Int, setter: (Int32) -> Void) {
412412
if unitFlags.contains(field) {
413413
setter(vector[compIndex])
414-
compIndex++
414+
compIndex += 1
415415
}
416416
}
417417

Foundation/NSDictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension Dictionary : _ObjectTypeBridgeable {
2222
let value = _NSObjectRepresentableBridge($0.1)
2323
keyBuffer.advancedBy(idx).initialize(key)
2424
valueBuffer.advancedBy(idx).initialize(value)
25-
idx++
25+
idx += 1
2626
}
2727

2828
let dict = NSDictionary(objects: valueBuffer, forKeys: keyBuffer, count: count)

Foundation/NSIndexSet.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
160160
guard idx < NSNotFound else {
161161
return nil
162162
}
163-
result++
163+
result += 1
164164
}
165165

166166
if let rangeIndex = _indexOfRangeAfterOrContainingIndex(result) {
@@ -173,7 +173,7 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
173173
guard idx > 0 else {
174174
return nil
175175
}
176-
result--
176+
result -= 1
177177
}
178178

179179
if let rangeIndex = _indexOfRangeBeforeOrContainingIndex(result) {
@@ -229,12 +229,13 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
229229
}
230230

231231
while idx <= maxIndex && counter < bufferSize && offset < currentRange.length {
232-
indexBuffer.advancedBy(counter++).memory = idx
233-
++idx
234-
++offset
232+
indexBuffer.advancedBy(counter).memory = idx
233+
counter += 1
234+
idx += 1
235+
offset += 1
235236
}
236237
if offset >= currentRange.length {
237-
++rangeIndex
238+
rangeIndex += 1
238239
offset = 0
239240
}
240241
}
@@ -266,7 +267,7 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
266267
return range.length
267268
}
268269
result = NSMaxRange(firstRange) - range.location
269-
rangeIndex++
270+
rangeIndex += 1
270271
}
271272

272273
for curRange in _ranges.suffixFrom(rangeIndex) {
@@ -518,7 +519,7 @@ public class NSMutableIndexSet : NSIndexSet {
518519
// overlaps
519520
if curEnd < nextEnd {
520521
self._replaceRangeAtIndex(rangeIndex, withRange: NSMakeRange(nextEnd - curRange.location, curRange.length))
521-
rangeIndex++
522+
rangeIndex += 1
522523
}
523524
self._replaceRangeAtIndex(rangeIndex + 1, withRange: nil)
524525
} else {
@@ -560,7 +561,7 @@ public class NSMutableIndexSet : NSIndexSet {
560561
// Proceed to merging
561562
break
562563
}
563-
rangeIndex++
564+
rangeIndex += 1
564565
}
565566
if let r = replacedRangeIndex {
566567
_mergeOverlappingRangesStartingAtIndex(r)
@@ -602,7 +603,7 @@ public class NSMutableIndexSet : NSIndexSet {
602603
} else if range.location > curRange.location && range.location < curEnd && removeEnd >= curEnd {
603604
_replaceRangeAtIndex(rangeIndex, withRange: NSMakeRange(curRange.location, range.location - curRange.location))
604605
}
605-
rangeIndex++
606+
rangeIndex += 1
606607
}
607608

608609
}

Foundation/NSPathUtilities.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ internal extension String {
8787

8888
while curPos < endPos {
8989
while curPos < endPos && characterView[curPos] == "/" {
90-
curPos++
90+
curPos = curPos.successor()
9191
}
9292
if curPos == endPos {
9393
break
9494
}
9595
var curEnd = curPos
9696
while curEnd < endPos && characterView[curEnd] != "/" {
97-
curEnd++
97+
curEnd = curEnd.successor()
9898
}
9999
result.append(String(characterView[curPos ..< curEnd]))
100100
curPos = curEnd
@@ -204,14 +204,14 @@ public extension NSString {
204204

205205
while curPos < endPos {
206206
while curPos < endPos && characterView[curPos] == "/" {
207-
curPos++
207+
curPos = curPos.successor()
208208
}
209209
if curPos == endPos {
210210
break
211211
}
212212
var curEnd = curPos
213213
while curEnd < endPos && characterView[curEnd] != "/" {
214-
curEnd++
214+
curEnd = curEnd.successor()
215215
}
216216
result.append(String(characterView[curPos ..< curEnd]))
217217
curPos = curEnd

Foundation/NSScanner.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ internal struct _NSStringBuffer {
143143

144144
mutating func advance() {
145145
if bufferLoc < bufferLen { /*buffer is OK*/
146-
curChar = buffer[bufferLoc++]
146+
curChar = buffer[bufferLoc]
147+
bufferLoc += 1
147148
} else if (_stringLoc + bufferLen < stringLen) { /* Buffer is empty but can be filled */
148149
_stringLoc += bufferLen
149150
fill()
@@ -155,7 +156,7 @@ internal struct _NSStringBuffer {
155156

156157
mutating func rewind() {
157158
if bufferLoc > 1 { /* Buffer is OK */
158-
bufferLoc--
159+
bufferLoc -= 1
159160
curChar = buffer[bufferLoc - 1]
160161
} else if _stringLoc > 0 { /* Buffer is empty but can be filled */
161162
bufferLoc = min(32, _stringLoc)
@@ -195,7 +196,8 @@ internal struct _NSStringBuffer {
195196
fill()
196197
}
197198
bufferLoc = newValue - _stringLoc
198-
curChar = buffer[bufferLoc++]
199+
curChar = buffer[bufferLoc]
200+
bufferLoc += 1
199201
}
200202
}
201203
}

Foundation/NSString.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ extension NSString {
753753
buf.rewind()
754754
if buf.currentCharacter == 0x0d {
755755
lineSeparatorLength = 2
756-
endOfContents--
756+
endOfContents -= 1
757757
}
758758
} else {
759759
while true {
@@ -938,15 +938,21 @@ extension NSString {
938938
let cfEncodings = CFStringGetListOfAvailableEncodings()
939939
var idx = 0
940940
var numEncodings = 0
941-
while cfEncodings.advancedBy(idx++).memory != kCFStringEncodingInvalidId {
942-
numEncodings++
941+
942+
while cfEncodings.advancedBy(idx).memory != kCFStringEncodingInvalidId {
943+
idx += 1
944+
numEncodings += 1
943945
}
944946

945947
let theEncodingList = UnsafeMutablePointer<NSStringEncoding>.alloc(numEncodings + 1)
946948
theEncodingList.advancedBy(numEncodings).memory = 0 // Terminator
947-
while --numEncodings >= 0 {
949+
950+
numEncodings -= 1
951+
while numEncodings >= 0 {
948952
theEncodingList.advancedBy(numEncodings).memory = CFStringConvertEncodingToNSStringEncoding(cfEncodings.advancedBy(numEncodings).memory)
953+
numEncodings -= 1
949954
}
955+
950956
return UnsafePointer<UInt>(theEncodingList)
951957
}()
952958
}
@@ -1399,7 +1405,7 @@ extension String {
13991405
var encodingArray = Array<NSStringEncoding>()
14001406
while encodings.advancedBy(numEncodings).memory != CoreFoundation.kCFStringEncodingInvalidId {
14011407
encodingArray.append(CFStringConvertEncodingToNSStringEncoding(encodings.advancedBy(numEncodings).memory))
1402-
numEncodings++
1408+
numEncodings += 1
14031409
}
14041410
return encodingArray
14051411
}

0 commit comments

Comments
 (0)