readVarint32 method
Implementation
int readVarint32() {
int result = 0;
int shift = 0;
if (trans_.getBytesRemainingInBuffer() >= 5) {
Int8List? buf = trans_.getBuffer();
if (buf == null) return 0;
int pos = trans_.getBufferPosition();
int off = 0;
while (true) {
int b = buf[pos + off].toSigned(8);
result |= (b & 0x7f) << shift;
if ((b & 0x80) != 0x80) {
break;
}
shift += 7;
off++;
}
trans_.consumeBuffer(off + 1);
} else {
while (true) {
int b = readByte().toSigned(8);
result |= (b & 0x7f) << shift;
if ((b & 0x80) != 0x80) {
break;
}
shift += 7;
}
}
return result;
}