Fix decoding
This commit is contained in:
parent
c6b51c98fb
commit
253017c429
@ -130,6 +130,8 @@ private func readElements<T>(from url: URL) throws -> [Timestamped<T>] where T:
|
||||
let file = url.lastPathComponent
|
||||
print("File \(file): Loaded \(data.count) bytes")
|
||||
|
||||
|
||||
|
||||
let decoder = CBORDecoder()
|
||||
let timestampLength = 9
|
||||
let byteCountLength = 2
|
||||
@ -159,7 +161,7 @@ private func readElements<T>(from url: URL) throws -> [Timestamped<T>] where T:
|
||||
let timestampData = data[startIndexOfTimestamp..<startIndexOfTimestamp+timestampLength]
|
||||
let timestamp = try decoder.decode(Double.self, from: timestampData)
|
||||
let date = Date(timeIntervalSince1970: timestamp)
|
||||
let elementData = data[currentIndex..<nextIndex]
|
||||
let elementData = data[startIndexOfTimestamp+timestampLength..<nextIndex]
|
||||
do {
|
||||
let element: T = try decoder.decode(from: elementData)
|
||||
result.append(.init(value: element, timestamp: date))
|
||||
|
Loading…
Reference in New Issue
Block a user