public int readVarInt ( boolean optimizePositive ) throws KryoException { if ( require ( 1 ) < 5 ) return readVarInt_slow ( optimizePositive ) ; int b = buffer [ position ++ ] ; int result = b & 0x7F ; if ( ( b & 0x80 ) != 0 ) { byte [ ] buffer = this . buffer ; int p = position ; b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 7 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 14 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 21 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 28 ; } } } position = p ; } return optimizePositive ? result : ( ( result >>> 1 ) ^ - ( result & 1 ) ) ; }
Reads a 1 - 5 byte int .