...
1
2
3
4
5
6 package fse
7
8
9
10
11
12 type byteReader struct {
13 b []byte
14 off int
15 }
16
17
18 func (b *byteReader) init(in []byte) {
19 b.b = in
20 b.off = 0
21 }
22
23
24 func (b *byteReader) advance(n uint) {
25 b.off += int(n)
26 }
27
28
29 func (b byteReader) Uint32() uint32 {
30 b2 := b.b[b.off:]
31 b2 = b2[:4]
32 v3 := uint32(b2[3])
33 v2 := uint32(b2[2])
34 v1 := uint32(b2[1])
35 v0 := uint32(b2[0])
36 return v0 | (v1 << 8) | (v2 << 16) | (v3 << 24)
37 }
38
39
40 func (b byteReader) unread() []byte {
41 return b.b[b.off:]
42 }
43
44
45 func (b byteReader) remain() int {
46 return len(b.b) - b.off
47 }
48
View as plain text