MCPcopy Create free account
hub / github.com/apache/fory / readVarUint32Slow

Method readVarUint32Slow

go/fory/buffer.go:1372–1400  ·  view source on GitHub ↗

Slow path reading (processing byte by byte)

(err *Error)

Source from the content-addressed store, hash-verified

1370
1371// Slow path reading (processing byte by byte)
1372func (b *ByteBuffer) readVarUint32Slow(err *Error) uint32 {
1373 var result uint32
1374 var shift uint
1375 for {
1376 if b.readerIndex >= len(b.data) {
1377 if !b.fill(1, err) {
1378 return 0
1379 }
1380 }
1381 byteVal := b.data[b.readerIndex]
1382 b.readerIndex++
1383 if shift == 28 && byteVal > 0x0F {
1384 if err != nil {
1385 *err = DeserializationError("VarUint32 overflow")
1386 }
1387 return 0
1388 }
1389 result |= (uint32(byteVal) & 0x7F) << shift
1390 if byteVal < 0x80 {
1391 break
1392 }
1393 shift += 7
1394 if shift >= 35 {
1395 *err = DeserializationError("VarUint32 overflow")
1396 return 0
1397 }
1398 }
1399 return result
1400}
1401
1402func (b *ByteBuffer) PutUint8(writerIndex int, value uint8) {
1403 b.data[writerIndex] = byte(value)

Callers 2

ReadVarUint32Method · 0.95
readVarUint32Small14Method · 0.95

Calls 3

fillMethod · 0.95
DeserializationErrorFunction · 0.85
uint32Function · 0.50

Tested by

no test coverage detected