Slow path reading (processing byte by byte)
(err *Error)
| 1370 | |
| 1371 | // Slow path reading (processing byte by byte) |
| 1372 | func (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 | |
| 1402 | func (b *ByteBuffer) PutUint8(writerIndex int, value uint8) { |
| 1403 | b.data[writerIndex] = byte(value) |
no test coverage detected