@@ -40,7 +40,7 @@ public class ByteReader {
4040 - Precondition: There MUST be enough data left.
4141 */
4242 public func byte( ) -> UInt8 {
43- precondition ( self . offset < self . size )
43+ precondition ( self . offset < self . data . endIndex )
4444 self . offset += 1
4545 return self . data [ self . offset - 1 ]
4646 }
@@ -55,7 +55,7 @@ public class ByteReader {
5555 precondition ( count >= 0 )
5656 guard count > 0
5757 else { return [ ] }
58- precondition ( self . offset + count <= self . size )
58+ precondition ( self . offset + count <= self . data . endIndex )
5959 let result = self . data [ self . offset..< self . offset + count] . toArray ( type: UInt8 . self, count: count)
6060 self . offset += count
6161 return result
@@ -67,7 +67,7 @@ public class ByteReader {
6767 - Precondition: There MUST be enough data left.
6868 */
6969 public func uint64( ) -> UInt64 {
70- precondition ( self . offset + 8 <= self . size )
70+ precondition ( self . offset + 8 <= self . data . endIndex )
7171 let result = self . data [ self . offset..< self . offset + 8 ] . to ( type: UInt64 . self)
7272 self . offset += 8
7373 return result
@@ -79,7 +79,7 @@ public class ByteReader {
7979 - Precondition: There MUST be enough data left.
8080 */
8181 public func uint32( ) -> UInt32 {
82- precondition ( self . offset + 4 <= self . size )
82+ precondition ( self . offset + 4 <= self . data . endIndex )
8383 let result = self . data [ self . offset..< self . offset + 4 ] . to ( type: UInt32 . self)
8484 self . offset += 4
8585 return result
@@ -91,7 +91,7 @@ public class ByteReader {
9191 - Precondition: There MUST be enough data left.
9292 */
9393 public func uint16( ) -> UInt16 {
94- precondition ( self . offset + 2 <= self . size )
94+ precondition ( self . offset + 2 <= self . data . endIndex )
9595 let result = self . data [ self . offset..< self . offset + 2 ] . to ( type: UInt16 . self)
9696 self . offset += 2
9797 return result
0 commit comments