Skip to content

Commit 82f8eee

Browse files
committed
Dont use zero index for setting currentByte in bit readers
1 parent 00536b9 commit 82f8eee

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

Sources/LsbBitReader.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ public final class LsbBitReader: ByteReader, BitReader {
2424

2525
/// Creates an instance for reading bits (and bytes) from `data`.
2626
public override init(data: Data) {
27-
if data.count > 0 {
28-
self.currentByte = data[0]
29-
} else {
30-
self.currentByte = 0
31-
}
27+
self.currentByte = data.first ?? 0
3228
super.init(data: data)
3329
}
3430

Sources/MsbBitReader.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ public final class MsbBitReader: ByteReader, BitReader {
2424

2525
/// Creates an instance for reading bits (and bytes) from `data`.
2626
public override init(data: Data) {
27-
if data.count > 0 {
28-
self.currentByte = data[0]
29-
} else {
30-
self.currentByte = 0
31-
}
27+
self.currentByte = data.first ?? 0
3228
super.init(data: data)
3329
}
3430

0 commit comments

Comments
 (0)