bits function of Data extension now checks if start is the same as the end.

This commit is contained in:
Timofey Solomko
2016-10-29 17:55:47 +03:00
parent dc6dffbb77
commit a2540d398c
2 changed files with 1 additions and 1 deletions
-1
View File
@@ -51,7 +51,6 @@ public class Deflate {
mtime: Data(data[4...7]).to(type: UInt64.self),
extraFlags: data[8],
osType: data[9])
print("\(serviceInfo)")
var startPoint = 10 // Index in data of 'actual data'
+1
View File
@@ -48,6 +48,7 @@ extension Data {
func bits(from start: (byte: Data.Index, bit: Data.Index),
to end: (byte: Data.Index, bit: Data.Index)) -> [UInt8] {
guard start != end else { return [] }
let bitsFromData: [UInt8] = Data(self[start.byte...end.byte])
.toArray(type: UInt8.self).map { $0.reversedBitOrder() }.reversed()
let bitsArray = bitsFromData.flatMap { $0.toUintArray() }