Skip to content

Commit

Permalink
Update to 05-03 snapshot
Browse files Browse the repository at this point in the history
* Updating to 04-25 snapshot

* Updating to 05.03 snapshot
  • Loading branch information
kiokumicu authored and paulofaria committed Jun 9, 2016
1 parent 6ac419e commit 68bb2f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-04-12-a
DEVELOPMENT-SNAPSHOT-2016-05-03-a
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import PackageDescription
let package = Package(
name: "Redis",
dependencies: [
.Package(url: "https://github.com/VeniceX/TCP.git", majorVersion: 0, minor: 5)
.Package(url: "https://github.com/VeniceX/TCP.git", majorVersion: 0, minor: 7)
]
)
12 changes: 6 additions & 6 deletions Sources/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extension String {

public func indexOf(character char: Character) -> Int? {
if let idx = self.characters.index(of: char) {
return self.startIndex.distance(to: idx)
return self.distance(from: self.startIndex, to: idx)
}
return nil
}
Expand All @@ -21,7 +21,7 @@ struct Parser {
static func readResponse(_ fullResponse: String) throws -> Any? {

let byte: Character = fullResponse[fullResponse.startIndex]
let response: String = fullResponse[fullResponse.startIndex.advanced(by: 1)..<fullResponse.endIndex]
let response: String = fullResponse[fullResponse.index(fullResponse.startIndex, offsetBy: 1)..<fullResponse.endIndex]

var result: Any?

Expand All @@ -34,18 +34,18 @@ struct Parser {
case ":":
// Simple integer
let idx = Int(response.indexOf(character: "\r\n")!)
result = Int(response[response.startIndex..<response.startIndex.advanced(by: idx)])
result = Int(response[response.startIndex..<response.index(response.startIndex, offsetBy: idx)])
case "+":
// Simple scleng
result = String(response)
case "$":
// Bulk string
let idx = Int(response.indexOf(character: "\r\n")!)
if response[response.startIndex..<response.startIndex.advanced(by: idx)] == "-1" {
if response[response.startIndex..<response.index(response.startIndex, offsetBy: idx)] == "-1" {
// nil string
result = nil
} else {
result = String(response[response.startIndex.advanced(by: idx)..<response.endIndex])
result = String(response[response.index(response.startIndex, offsetBy: idx)..<response.endIndex])
}

case "*":
Expand All @@ -61,7 +61,7 @@ struct Parser {

while values.count > 0 {
var tmp: [Any?] = []
let tail: Int = Int(String(values[0][values[0].startIndex.advanced(by: 1)]))!
let tail: Int = Int(String(values[0][values[0].index(values[0].startIndex, offsetBy: 1)]))!

values.remove(at: 0)
while tmp.count < tail {
Expand Down

0 comments on commit 68bb2f6

Please sign in to comment.