MCPcopy
hub / github.com/segmentio/kafka-go / readUnsignedVarInt

Method readUnsignedVarInt

protocol/decode.go:306–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

304}
305
306func (d *decoder) readUnsignedVarInt() uint64 {
307 n := 11 // varints are at most 11 bytes
308
309 if n > d.remain {
310 n = d.remain
311 }
312
313 x := uint64(0)
314 s := uint(0)
315
316 for n > 0 {
317 b := d.readByte()
318
319 if (b & 0x80) == 0 {
320 x |= uint64(b) << s
321 return x
322 }
323
324 x |= uint64(b&0x7f) << s
325 s += 7
326 n--
327 }
328
329 d.setError(fmt.Errorf("cannot decode unsigned varint from input stream"))
330 return 0
331}
332
333type decodeFunc func(*decoder, value)
334

Callers 7

TestVarIntsFunction · 0.95
ReadRequestFunction · 0.95
decodeCompactArrayMethod · 0.95
readCompactStringMethod · 0.95
readCompactBytesMethod · 0.95
ReadResponseFunction · 0.95
structDecodeFuncOfFunction · 0.80

Calls 2

readByteMethod · 0.95
setErrorMethod · 0.95

Tested by 1

TestVarIntsFunction · 0.76