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

Method init

zstd/bitreader.go:27–48  ·  view source on GitHub ↗

init initializes and resets the bit reader.

(in []byte)

Source from the content-addressed store, hash-verified

25
26// init initializes and resets the bit reader.
27func (b *bitReader) init(in []byte) error {
28 if len(in) < 1 {
29 return errors.New("corrupt stream: too short")
30 }
31 b.in = in
32 // The highest bit of the last byte indicates where to start
33 v := in[len(in)-1]
34 if v == 0 {
35 return errors.New("corrupt stream, did not find end of stream")
36 }
37 b.cursor = len(in)
38 b.bitsRead = 64
39 b.value = 0
40 if len(in) >= 8 {
41 b.fillFastStart()
42 } else {
43 b.fill()
44 b.fill()
45 }
46 b.bitsRead += 8 - uint8(highBits(uint32(v)))
47 return nil
48}
49
50// getBits will return n bits. n can be 0.
51func (b *bitReader) getBits(n uint8) int {

Callers

nothing calls this directly

Calls 3

fillFastStartMethod · 0.95
fillMethod · 0.95
highBitsFunction · 0.70

Tested by

no test coverage detected