mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
bits function of Data extension now checks if start is the same as the end.
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -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() }
|
||||
|
||||
Reference in New Issue
Block a user