decodeVarint function
Decodes one varint from bytes at start. Returns (value, nextIndex).
Implementation
(int value, int next) decodeVarint(List<int> bytes, int start) {
int value = 0;
int shift = 0;
int i = start;
while (i < bytes.length) {
final int b = bytes[i++];
value |= (b & 0x7f) << shift;
if ((b & 0x80) == 0) return (value, i);
shift += 7;
if (shift > 35) break;
}
return (value, i);
}