readVarInt method

int readVarInt()

Reads a variable-length signed integer. Compatible with Protocol Buffers encoding.

Implementation

int readVarInt() {
  final value = readVarUint();
  if (value % 2 == 0) {
    return value ~/ 2;
  }
  return (value ~/ -2) - 1;
}