Skip to content

Commit 5762a64

Browse files
committed
Change implementation of didSet observer of offset property in bit readers to a more efficient version (using _offset and ptr)
This requires making ByteReader._offset internal instead of private.
1 parent 5f8e2d1 commit 5762a64

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Sources/ByteReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ByteReader {
2424
}
2525
}
2626

27-
private var _offset: Int
27+
var _offset: Int
2828

2929
var ptr: UnsafeBufferPointer<UInt8>
3030

Sources/LsbBitReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public final class LsbBitReader: ByteReader, BitReader {
257257
public override var offset: Int {
258258
didSet {
259259
if !self.isFinished {
260-
self.currentByte = self.data[self.offset]
260+
self.currentByte = self.ptr[self._offset]
261261
}
262262
}
263263
}

Sources/MsbBitReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public final class MsbBitReader: ByteReader, BitReader {
257257
public override var offset: Int {
258258
didSet {
259259
if !self.isFinished {
260-
self.currentByte = self.data[self.offset]
260+
self.currentByte = self.ptr[self._offset]
261261
}
262262
}
263263
}

0 commit comments

Comments
 (0)