Index: src/java/org/apache/lucene/store/IndexInput.java
===================================================================
--- src/java/org/apache/lucene/store/IndexInput.java	(revision 902547)
+++ src/java/org/apache/lucene/store/IndexInput.java	(working copy)
@@ -22,6 +22,8 @@
 import java.util.Map;
 import java.util.HashMap;
 
+import org.apache.lucene.util.ArrayUtil;
+
 /** Abstract base class for input from a file in a {@link Directory}.  A
  * random-access input stream.  Used for all Lucene index input operations.
  * @see Directory
@@ -64,6 +66,13 @@
     readBytes(b, offset, len);
   }
 
+  /** Reads two bytes of an unsigned 16 bit integer and returns an int.
+   * @see IndexOutput#writeShort(int)
+   */
+  public int readShort() throws IOException {
+    return ((readByte() & 0xFF) <<  8) |  (readByte() & 0xFF);
+  }
+
   /** Reads four bytes and returns an int.
    * @see IndexOutput#writeInt(int)
    */
@@ -72,12 +81,12 @@
          | ((readByte() & 0xFF) <<  8) |  (readByte() & 0xFF);
   }
 
-  /** Reads an int stored in variable-length format.  Reads between one and
+  /** Reads an int stored in variable byte length format.  Reads between one and
    * five bytes.  Smaller values take fewer bytes.  Negative numbers are not
    * supported.
    * @see IndexOutput#writeVInt(int)
    */
-  public int readVInt() throws IOException {
+   public int readVInt() throws IOException { // CHECKME: rename to readVByteInt ?
     byte b = readByte();
     int i = b & 0x7F;
     for (int shift = 7; (b & 0x80) != 0; shift += 7) {
@@ -87,6 +96,27 @@
     return i;
   }
 
+  /** Reads an int stored in variable short length format.  Reads two, four
+   * or six bytes.  Smaller values take fewer bytes.  Negative numbers are not
+   * supported.
+   * @see IndexOutput#writeVShortInt(int)
+   */
+  public int readVShortInt() throws IOException {
+    int s = readShort();
+    int i = s & 0x7FFF;
+    if ((s & 0x8000) == 0) {
+      return i;
+    }
+    s = readShort();
+    i |= (s & 0x7FFF) << 15;
+    if ((s & 0x8000) == 0) {
+      return i;
+    }
+    s = readShort();
+    assert (s & 0xFFFFFFFE) == 0; // only 31st bit, negative numbers not supported
+    return i | ((s & 0x7FFF) << 30);
+  }
+
   /** Reads eight bytes and returns a long.
    * @see IndexOutput#writeLong(long)
    */
@@ -122,16 +152,18 @@
     if (preUTF8Strings)
       return readModifiedUTF8String();
     int length = readVInt();
-    if (bytes == null || length > bytes.length)
-      bytes = new byte[(int) (length*1.25)];
+    if (bytes == null || length > bytes.length) {
+      bytes = new byte[ArrayUtil.oversize(length, 1)];
+    }
     readBytes(bytes, 0, length);
     return new String(bytes, 0, length, "UTF-8");
   }
 
   private String readModifiedUTF8String() throws IOException {
     int length = readVInt();
-    if (chars == null || length > chars.length)
+    if (chars == null || length > chars.length) {
       chars = new char[length];
+    }
     readChars(chars, 0, length);
     return new String(chars, 0, length);
   }
@@ -157,10 +189,11 @@
       else if ((b & 0xE0) != 0xE0) {
 	buffer[i] = (char)(((b & 0x1F) << 6)
 		 | (readByte() & 0x3F));
-      } else
+      } else {
 	buffer[i] = (char)(((b & 0x0F) << 12)
 		| ((readByte() & 0x3F) << 6)
 	        |  (readByte() & 0x3F));
+      }
     }
   }
 
@@ -181,10 +214,9 @@
       byte b = readByte();
       if ((b & 0x80) == 0){
         //do nothing, we only need one byte
-      }
-      else if ((b & 0xE0) != 0xE0) {
+      } else if ((b & 0xE0) != 0xE0) {
         readByte();//read an additional byte
-      } else{      
+      } else {      
         //read two additional bytes.
         readByte();
         readByte();
Index: src/java/org/apache/lucene/store/IndexOutput.java
===================================================================
--- src/java/org/apache/lucene/store/IndexOutput.java	(revision 902547)
+++ src/java/org/apache/lucene/store/IndexOutput.java	(working copy)
@@ -53,6 +53,14 @@
    */
   public abstract void writeBytes(byte[] b, int offset, int length) throws IOException;
 
+  /** Writes the lower 16 bits of an int as two bytes.
+   * @see IndexInput#readShort()
+   */
+  public void writeShort(int i) throws IOException {
+    writeByte((byte)(i >> 8));
+    writeByte((byte) i);
+  }
+
   /** Writes an int as four bytes.
    * @see IndexInput#readInt()
    */
@@ -63,19 +71,32 @@
     writeByte((byte) i);
   }
 
-  /** Writes an int in a variable-length format.  Writes between one and
+  /** Writes an int in a variable byte length format.  Writes between one and
    * five bytes.  Smaller values take fewer bytes.  Negative numbers are not
    * supported.
    * @see IndexInput#readVInt()
    */
-  public void writeVInt(int i) throws IOException {
+ public void writeVInt(int i) throws IOException { // CHECKME: rename to writeVByteInt ?
     while ((i & ~0x7F) != 0) {
-      writeByte((byte)((i & 0x7f) | 0x80));
+      writeByte((byte)((i & 0x7F) | 0x80));
       i >>>= 7;
     }
     writeByte((byte)i);
   }
 
+  /** Writes an int in a variable short length format.  Writes two, four or
+   * six bytes.  Smaller values take fewer bytes.  Negative numbers are not
+   * supported.
+   * @see IndexInput#readVShortInt()
+   */
+  public void writeVShortInt(int i) throws IOException {
+    while ((i & ~0x7FFF) != 0) {
+      writeShort((i & 0x7FFF) | 0x8000);
+      i >>>= 15;
+    }
+    writeShort(i);
+  }
+
   /** Writes a long as eight bytes.
    * @see IndexInput#readLong()
    */
@@ -84,7 +105,7 @@
     writeInt((int) i);
   }
 
-  /** Writes an long in a variable-length format.  Writes between one and five
+  /** Writes an long in a variable-length format.  Writes between one and nine
    * bytes.  Smaller values take fewer bytes.  Negative numbers are not
    * supported.
    * @see IndexInput#readVLong()
@@ -158,6 +179,13 @@
       }
     }
   }
+  
+  public void writeInts(int[] ar, int start, int length, CompressionMethod cm) throws IOException {
+    throw new UnsupportedOperationException();
+  }
+  
+  public class CompressionMethod {
+  }
 
   private static int COPY_BUFFER_SIZE = 16384;
   private byte[] copyBuffer;
Index: src/java/org/apache/lucene/index/FormatPostingsPositionsWriter.java
===================================================================
--- src/java/org/apache/lucene/index/FormatPostingsPositionsWriter.java	(revision 902547)
+++ src/java/org/apache/lucene/index/FormatPostingsPositionsWriter.java	(working copy)
@@ -60,14 +60,15 @@
     if (storePayloads) {
       if (payloadLength != lastPayloadLength) {
         lastPayloadLength = payloadLength;
-        out.writeVInt((delta<<1)|1);
+        out.writeVShortInt((delta<<1)|1);
         out.writeVInt(payloadLength);
       } else
-        out.writeVInt(delta << 1);
+        out.writeVShortInt(delta << 1);
       if (payloadLength > 0)
         out.writeBytes(payload, payloadLength);
-    } else
-      out.writeVInt(delta);
+    } else {
+      out.writeVShortInt(delta);
+    }
   }
 
   void setField(FieldInfo fieldInfo) {
Index: src/java/org/apache/lucene/index/SegmentTermPositions.java
===================================================================
--- src/java/org/apache/lucene/index/SegmentTermPositions.java	(revision 902547)
+++ src/java/org/apache/lucene/index/SegmentTermPositions.java	(working copy)
@@ -72,7 +72,7 @@
   }
 
   private final int readDeltaPosition() throws IOException {
-    int delta = proxStream.readVInt();
+    int delta = proxStream.readVShortInt();
     if (currentFieldStoresPayloads) {
       // if the current field stores payloads then
       // the position delta is shifted one bit to the left.
