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,10 +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; - } + 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(); + i |= (b & 0x7F) << 28; return i; } @@ -99,11 +107,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; - } + 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(); + i |= (b & 0x7FL) << 56; return i; }