simplify ranges
This commit is contained in:
parent
11bc8e5df2
commit
f0ac68e369
@ -119,7 +119,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dataArray = String(message.utf16[message.utf16.index(reader.currentIndex, offsetBy: 1)..<message.utf16.endIndex])!
|
var dataArray = String(message.utf16[message.utf16.index(reader.currentIndex, offsetBy: 1)...])!
|
||||||
|
|
||||||
if type == .error && !dataArray.hasPrefix("[") && !dataArray.hasSuffix("]") {
|
if type == .error && !dataArray.hasPrefix("[") && !dataArray.hasSuffix("]") {
|
||||||
dataArray = "[" + dataArray + "]"
|
dataArray = "[" + dataArray + "]"
|
||||||
|
|||||||
@ -54,7 +54,7 @@ struct SocketStringReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutating func readUntilOccurence(of string: String) -> String {
|
mutating func readUntilOccurence(of string: String) -> String {
|
||||||
let substring = message.utf16[currentIndex..<message.utf16.endIndex]
|
let substring = message.utf16[currentIndex...]
|
||||||
|
|
||||||
guard let foundIndex = substring.index(of: string.utf16.first!) else {
|
guard let foundIndex = substring.index(of: string.utf16.first!) else {
|
||||||
currentIndex = message.utf16.endIndex
|
currentIndex = message.utf16.endIndex
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user