Index: lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java =================================================================== --- lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java (revision 1305885) +++ lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java (working copy) @@ -17,14 +17,11 @@ * limitations under the License. */ -import java.io.IOException; - import org.apache.lucene.util.BytesRef; /** * DataInput backed by a byte array. - * WARNING: This class omits most low-level checks, - * so be sure to test heavily with assertions enabled. + * WARNING: This class omits all low-level checks. * @lucene.experimental */ public final class ByteArrayDataInput extends DataInput { @@ -80,7 +77,6 @@ public void skipBytes(int count) { pos += count; - assert pos <= limit; } @Override @@ -90,14 +86,12 @@ @Override public int readInt() { - assert pos+4 <= limit; return ((bytes[pos++] & 0xFF) << 24) | ((bytes[pos++] & 0xFF) << 16) | ((bytes[pos++] & 0xFF) << 8) | (bytes[pos++] & 0xFF); } @Override public long readLong() { - assert pos+8 <= limit; final int i1 = ((bytes[pos++] & 0xff) << 24) | ((bytes[pos++] & 0xff) << 16) | ((bytes[pos++] & 0xff) << 8) | (bytes[pos++] & 0xff); final int i2 = ((bytes[pos++] & 0xff) << 24) | ((bytes[pos++] & 0xff) << 16) | @@ -107,23 +101,18 @@ @Override public int readVInt() { - assert checkBounds(); byte b = bytes[pos++]; int i = b & 0x7F; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7F) << 7; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7F) << 14; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7F) << 21; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; // Warning: the next ands use 0x0F / 0xF0 - beware copy/paste errors: i |= (b & 0x0F) << 28; @@ -133,39 +122,30 @@ @Override public long readVLong() { - assert checkBounds(); byte b = bytes[pos++]; long i = b & 0x7FL; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 7; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 14; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 21; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 28; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 35; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 42; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 49; if ((b & 0x80) == 0) return i; - assert checkBounds(); b = bytes[pos++]; i |= (b & 0x7FL) << 56; if ((b & 0x80) == 0) return i; @@ -175,19 +155,13 @@ // NOTE: AIOOBE not EOF if you read too much @Override public byte readByte() { - assert checkBounds(); return bytes[pos++]; } // NOTE: AIOOBE not EOF if you read too much @Override public void readBytes(byte[] b, int offset, int len) { - assert pos + len <= limit; System.arraycopy(bytes, pos, b, offset, len); pos += len; } - - private boolean checkBounds() { - return pos < limit; - } }