MCPcopy Create free account
hub / github.com/dotabuff/manta / readBytes

Method readBytes

reader.go:162–180  ·  view source on GitHub ↗

readBytes reads the given number of bytes

(n uint32)

Source from the content-addressed store, hash-verified

160
161// readBytes reads the given number of bytes
162func (r *reader) readBytes(n uint32) []byte {
163 // Fast path if we're byte aligned
164 if r.bitCount&7 == 0 {
165 if r.bitCount != 0 {
166 r.realign()
167 }
168 r.pos += n
169 if r.pos > r.size {
170 _panicf("readBytes: insufficient buffer (%d of %d)", r.pos, r.size)
171 }
172 return r.buf[r.pos-n : r.pos]
173 }
174
175 buf := make([]byte, n)
176 for i := uint32(0); i < n; i++ {
177 buf[i] = byte(r.readBits(8))
178 }
179 return buf
180}
181
182// readLeUint32 reads an little-endian uint32
183func (r *reader) readLeUint32() uint32 {

Callers 3

readLeUint32Method · 0.95
readLeUint64Method · 0.95
readStringNMethod · 0.95

Calls 3

realignMethod · 0.95
readBitsMethod · 0.95
_panicfFunction · 0.85

Tested by

no test coverage detected