@@ -270,7 +270,7 @@ public final class LsbBitReader: ByteReader, BitReader {
270270 */
271271 public override func byte( ) -> UInt8 {
272272 precondition ( isAligned, " BitReader is not aligned. " )
273- defer { self . currentByte = self . ptr [ self . _offset] }
273+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
274274 return super. byte ( )
275275 }
276276
@@ -282,7 +282,7 @@ public final class LsbBitReader: ByteReader, BitReader {
282282 */
283283 public override func bytes( count: Int ) -> [ UInt8 ] {
284284 precondition ( isAligned, " BitReader is not aligned. " )
285- defer { self . currentByte = self . ptr [ self . _offset] }
285+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
286286 return super. bytes ( count: count)
287287 }
288288
@@ -295,7 +295,7 @@ public final class LsbBitReader: ByteReader, BitReader {
295295 */
296296 public override func int( fromBytes count: Int ) -> Int {
297297 precondition ( isAligned, " BitReader is not aligned. " )
298- defer { self . currentByte = self . ptr [ self . _offset] }
298+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
299299 return super. int ( fromBytes: count)
300300 }
301301
@@ -307,7 +307,7 @@ public final class LsbBitReader: ByteReader, BitReader {
307307 */
308308 public override func uint64( ) -> UInt64 {
309309 precondition ( isAligned, " BitReader is not aligned. " )
310- defer { self . currentByte = self . ptr [ self . _offset] }
310+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
311311 return super. uint64 ( fromBytes: 8 )
312312 }
313313
@@ -320,7 +320,7 @@ public final class LsbBitReader: ByteReader, BitReader {
320320 */
321321 public override func uint64( fromBytes count: Int ) -> UInt64 {
322322 precondition ( isAligned, " BitReader is not aligned. " )
323- defer { self . currentByte = self . ptr [ self . _offset] }
323+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
324324 return super. uint64 ( fromBytes: count)
325325 }
326326
@@ -332,7 +332,7 @@ public final class LsbBitReader: ByteReader, BitReader {
332332 */
333333 public override func uint32( ) -> UInt32 {
334334 precondition ( isAligned, " BitReader is not aligned. " )
335- defer { self . currentByte = self . ptr [ self . _offset] }
335+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
336336 return super. uint32 ( fromBytes: 4 )
337337 }
338338
@@ -345,7 +345,7 @@ public final class LsbBitReader: ByteReader, BitReader {
345345 */
346346 public override func uint32( fromBytes count: Int ) -> UInt32 {
347347 precondition ( isAligned, " BitReader is not aligned. " )
348- defer { self . currentByte = self . ptr [ self . _offset] }
348+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
349349 return super. uint32 ( fromBytes: count)
350350 }
351351
@@ -357,7 +357,7 @@ public final class LsbBitReader: ByteReader, BitReader {
357357 */
358358 public override func uint16( ) -> UInt16 {
359359 precondition ( isAligned, " BitReader is not aligned. " )
360- defer { self . currentByte = self . ptr [ self . _offset] }
360+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
361361 return super. uint16 ( fromBytes: 2 )
362362 }
363363
@@ -370,7 +370,7 @@ public final class LsbBitReader: ByteReader, BitReader {
370370 */
371371 public override func uint16( fromBytes count: Int ) -> UInt16 {
372372 precondition ( isAligned, " BitReader is not aligned. " )
373- defer { self . currentByte = self . ptr [ self . _offset] }
373+ defer { if ! self . isFinished { self . currentByte = self . ptr [ self . _offset] } }
374374 return super. uint16 ( fromBytes: count)
375375 }
376376
0 commit comments