Skip to content

Remove ++ and -- operators #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Foundation/NSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ public class NSMutableArray : NSArray {

var objectIdx = 0
indexes.enumerateIndexesUsingBlock() { (insertionIndex, _) in
self.insertObject(objects[objectIdx++], atIndex: insertionIndex)
self.insertObject(objects[objectIdx], atIndex: insertionIndex)
objectIdx += 1
}
}

Expand Down
6 changes: 4 additions & 2 deletions Foundation/NSCFDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ internal final class _NSCFDictionary : NSMutableDictionary {
if index == count {
return nil
} else {
return keyArray[index++]
let item = keyArray[index]
index += 1
return item
}
}

Expand Down Expand Up @@ -139,7 +141,7 @@ internal func _CFSwiftDictionaryGetKeysAndValues(dictionary: AnyObject, keybuf:
(dictionary as! NSDictionary).enumerateKeysAndObjectsUsingBlock { key, value, _ in
keybuf[idx] = Unmanaged<AnyObject>.passUnretained(key)
valuebuf[idx] = Unmanaged<AnyObject>.passUnretained(value)
idx++
idx += 1
}
}

Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
private func _setComp(unitFlags: NSCalendarUnit, field: NSCalendarUnit, vector: [Int32], inout compIndex: Int, setter: (Int32) -> Void) {
if unitFlags.contains(field) {
setter(vector[compIndex])
compIndex++
compIndex += 1
}
}

Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension Dictionary : _ObjectTypeBridgeable {
let value = _NSObjectRepresentableBridge($0.1)
keyBuffer.advancedBy(idx).initialize(key)
valueBuffer.advancedBy(idx).initialize(value)
idx++
idx += 1
}

let dict = NSDictionary(objects: valueBuffer, forKeys: keyBuffer, count: count)
Expand Down
21 changes: 11 additions & 10 deletions Foundation/NSIndexSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
guard idx < NSNotFound else {
return nil
}
result++
result += 1
}

if let rangeIndex = _indexOfRangeAfterOrContainingIndex(result) {
Expand All @@ -173,7 +173,7 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
guard idx > 0 else {
return nil
}
result--
result -= 1
}

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

while idx <= maxIndex && counter < bufferSize && offset < currentRange.length {
indexBuffer.advancedBy(counter++).memory = idx
++idx
++offset
indexBuffer.advancedBy(counter).memory = idx
counter += 1
idx += 1
offset += 1
}
if offset >= currentRange.length {
++rangeIndex
rangeIndex += 1
offset = 0
}
}
Expand Down Expand Up @@ -266,7 +267,7 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
return range.length
}
result = NSMaxRange(firstRange) - range.location
rangeIndex++
rangeIndex += 1
}

for curRange in _ranges.suffixFrom(rangeIndex) {
Expand Down Expand Up @@ -518,7 +519,7 @@ public class NSMutableIndexSet : NSIndexSet {
// overlaps
if curEnd < nextEnd {
self._replaceRangeAtIndex(rangeIndex, withRange: NSMakeRange(nextEnd - curRange.location, curRange.length))
rangeIndex++
rangeIndex += 1
}
self._replaceRangeAtIndex(rangeIndex + 1, withRange: nil)
} else {
Expand Down Expand Up @@ -560,7 +561,7 @@ public class NSMutableIndexSet : NSIndexSet {
// Proceed to merging
break
}
rangeIndex++
rangeIndex += 1
}
if let r = replacedRangeIndex {
_mergeOverlappingRangesStartingAtIndex(r)
Expand Down Expand Up @@ -602,7 +603,7 @@ public class NSMutableIndexSet : NSIndexSet {
} else if range.location > curRange.location && range.location < curEnd && removeEnd >= curEnd {
_replaceRangeAtIndex(rangeIndex, withRange: NSMakeRange(curRange.location, range.location - curRange.location))
}
rangeIndex++
rangeIndex += 1
}

}
Expand Down
8 changes: 4 additions & 4 deletions Foundation/NSPathUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ internal extension String {

while curPos < endPos {
while curPos < endPos && characterView[curPos] == "/" {
curPos++
curPos = curPos.successor()
}
if curPos == endPos {
break
}
var curEnd = curPos
while curEnd < endPos && characterView[curEnd] != "/" {
curEnd++
curEnd = curEnd.successor()
}
result.append(String(characterView[curPos ..< curEnd]))
curPos = curEnd
Expand Down Expand Up @@ -204,14 +204,14 @@ public extension NSString {

while curPos < endPos {
while curPos < endPos && characterView[curPos] == "/" {
curPos++
curPos = curPos.successor()
}
if curPos == endPos {
break
}
var curEnd = curPos
while curEnd < endPos && characterView[curEnd] != "/" {
curEnd++
curEnd = curEnd.successor()
}
result.append(String(characterView[curPos ..< curEnd]))
curPos = curEnd
Expand Down
8 changes: 5 additions & 3 deletions Foundation/NSScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ internal struct _NSStringBuffer {

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

mutating func rewind() {
if bufferLoc > 1 { /* Buffer is OK */
bufferLoc--
bufferLoc -= 1
curChar = buffer[bufferLoc - 1]
} else if _stringLoc > 0 { /* Buffer is empty but can be filled */
bufferLoc = min(32, _stringLoc)
Expand Down Expand Up @@ -195,7 +196,8 @@ internal struct _NSStringBuffer {
fill()
}
bufferLoc = newValue - _stringLoc
curChar = buffer[bufferLoc++]
curChar = buffer[bufferLoc]
bufferLoc += 1
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions Foundation/NSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ extension NSString {
buf.rewind()
if buf.currentCharacter == 0x0d {
lineSeparatorLength = 2
endOfContents--
endOfContents -= 1
}
} else {
while true {
Expand Down Expand Up @@ -938,15 +938,21 @@ extension NSString {
let cfEncodings = CFStringGetListOfAvailableEncodings()
var idx = 0
var numEncodings = 0
while cfEncodings.advancedBy(idx++).memory != kCFStringEncodingInvalidId {
numEncodings++

while cfEncodings.advancedBy(idx).memory != kCFStringEncodingInvalidId {
idx += 1
numEncodings += 1
}

let theEncodingList = UnsafeMutablePointer<NSStringEncoding>.alloc(numEncodings + 1)
theEncodingList.advancedBy(numEncodings).memory = 0 // Terminator
while --numEncodings >= 0 {

numEncodings -= 1
while numEncodings >= 0 {
theEncodingList.advancedBy(numEncodings).memory = CFStringConvertEncodingToNSStringEncoding(cfEncodings.advancedBy(numEncodings).memory)
numEncodings -= 1
}

return UnsafePointer<UInt>(theEncodingList)
}()
}
Expand Down Expand Up @@ -1399,7 +1405,7 @@ extension String {
var encodingArray = Array<NSStringEncoding>()
while encodings.advancedBy(numEncodings).memory != CoreFoundation.kCFStringEncodingInvalidId {
encodingArray.append(CFStringConvertEncodingToNSStringEncoding(encodings.advancedBy(numEncodings).memory))
numEncodings++
numEncodings += 1
}
return encodingArray
}
Expand Down