camdenorrb
11/13/2016, 11:00 AMfun ByteBuf.readVarInt(): Int {
var value = 0
var i = 0
var b: Int
while ((b = byteBuf.readByte().toInt()) and 0x80 != 0) {
value = value or (b and 0x7F shl i)
i += 7
if (i > 35) {
throw IllegalArgumentException("Variable length quantity is too long")
}
}
return value or (b shl i)
}