Skip to content
Open
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
6 changes: 4 additions & 2 deletions swift/lib/ProtocGenSwift/ProtocGenSwift/ProtobufReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class ProtobufReader : Reader {
if limit != -1 && offset == limit {
return 0
}
return _readByte(offset++)
let readByte = _readByte(offset)
offset += 1
return readByte
}

public func readVarInt() -> Int {
Expand Down Expand Up @@ -70,7 +72,7 @@ public class ProtobufReader : Reader {
let numberOfBytes = self.readVarInt()
let data = NSMutableData(capacity: numberOfBytes)!
let ptr = UnsafeMutablePointer<UInt8>(data.bytes)
for var i = 0; i < numberOfBytes; i++ {
for i in 0..<numberOfBytes {
ptr[i] = self.readByte()
}
return data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class ProtobufWriter : Writer {
let numberOfBytes = v.length
self.writeVarInt(numberOfBytes)
let ptr = UnsafePointer<UInt8>(v.bytes)
for var i = 0; i < numberOfBytes; i++ {
for i in 0..<numberOfBytes {
self.writeByte(ptr[i])
}
}
Expand Down
2 changes: 1 addition & 1 deletion swift/lib/ProtocGenSwift/ProtocGenSwiftTests/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private func sizeOfVarInt(v: Int) -> Int {
var x = v
repeat {
x = x >> 7
n++
n += 1
} while (x > 0)
return n
}
Expand Down