Slow path (read byte by byte)
(err *Error)
| 1226 | |
| 1227 | // Slow path (read byte by byte) |
| 1228 | func (b *ByteBuffer) readVarUint64Slow(err *Error) uint64 { |
| 1229 | var result uint64 |
| 1230 | var shift uint |
| 1231 | for i := 0; i < 8; i++ { |
| 1232 | if b.readerIndex >= len(b.data) { |
| 1233 | if !b.fill(1, err) { |
| 1234 | return 0 |
| 1235 | } |
| 1236 | } |
| 1237 | byteVal := b.data[b.readerIndex] |
| 1238 | b.readerIndex++ |
| 1239 | result |= (uint64(byteVal) & 0x7F) << shift |
| 1240 | if byteVal < 0x80 { |
| 1241 | return result |
| 1242 | } |
| 1243 | shift += 7 |
| 1244 | } |
| 1245 | if b.readerIndex >= len(b.data) { |
| 1246 | if !b.fill(1, err) { |
| 1247 | return 0 |
| 1248 | } |
| 1249 | } |
| 1250 | byteVal := b.data[b.readerIndex] |
| 1251 | b.readerIndex++ |
| 1252 | return result | (uint64(byteVal) << 56) |
| 1253 | } |
| 1254 | |
| 1255 | // Auxiliary function |
| 1256 | func (b *ByteBuffer) remaining() int { |
no test coverage detected