MCPcopy
hub / github.com/klauspost/compress / init

Method init

huff0/bitreader.go:136–157  ·  view source on GitHub ↗

init initializes and resets the bit reader.

(in []byte)

Source from the content-addressed store, hash-verified

134
135// init initializes and resets the bit reader.
136func (b *bitReaderShifted) init(in []byte) error {
137 if len(in) < 1 {
138 return errors.New("corrupt stream: too short")
139 }
140 b.in = in
141 b.off = uint(len(in))
142 // The highest bit of the last byte indicates where to start
143 v := in[len(in)-1]
144 if v == 0 {
145 return errors.New("corrupt stream, did not find end of stream")
146 }
147 b.bitsRead = 64
148 b.value = 0
149 if len(in) >= 8 {
150 b.fillFastStart()
151 } else {
152 b.fill()
153 b.fill()
154 }
155 b.advance(8 - uint8(highBit32(uint32(v))))
156 return nil
157}
158
159// peekBitsFast requires that at least one bit is requested every time.
160// There are no checks if the buffer is filled.

Callers 2

Decompress1XMethod · 0.95
Decompress1XMethod · 0.95

Calls 4

fillFastStartMethod · 0.95
fillMethod · 0.95
advanceMethod · 0.95
highBit32Function · 0.85

Tested by

no test coverage detected