Index: lucene/src/java/org/apache/lucene/store/IndexInput.java =================================================================== --- lucene/src/java/org/apache/lucene/store/IndexInput.java (revision 1083087) +++ lucene/src/java/org/apache/lucene/store/IndexInput.java (working copy) @@ -80,11 +80,18 @@ public int readVInt() throws IOException { byte b = readByte(); int i = b & 0x7F; - for (int shift = 7; (b & 0x80) != 0; shift += 7) { - b = readByte(); - i |= (b & 0x7F) << shift; - } - return i; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7F) << 7; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7F) << 14; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7F) << 21; + if ((b & 0x80) == 0) return i; + b = readByte(); + return i | (b & 0x7F) << 28; } /** Reads eight bytes and returns a long. @@ -99,12 +106,31 @@ * supported. */ public long readVLong() throws IOException { byte b = readByte(); - long i = b & 0x7F; - for (int shift = 7; (b & 0x80) != 0; shift += 7) { - b = readByte(); - i |= (b & 0x7FL) << shift; - } - return i; + long i = b & 0x7FL; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 7; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 14; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 21; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 28; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 35; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 42; + if ((b & 0x80) == 0) return i; + b = readByte(); + i |= (b & 0x7FL) << 49; + if ((b & 0x80) == 0) return i; + b = readByte(); + return i | (b & 0x7FL) << 56; } /** Call this if readString should read characters stored