Apache Lucene open-source search software
LUCENE-3738: Remove the asserts in this class (in most cases not useful, only useful if limit<b.length
Uwe Schindler46724924e40f
diff --git a/lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java b/lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.javaindex 90391494872..7be30258d5d 100644--- a/lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java+++ b/lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java@@ -17,14 +17,11 @@ package org.apache.lucene.store;* limitations under the License.*/-import java.io.IOException;-import org.apache.lucene.util.BytesRef;/*** DataInput backed by a byte array.- * <b>WARNING:</b> This class omits most low-level checks,- * so be sure to test heavily with assertions enabled.+ * <b>WARNING:</b> This class omits all low-level checks.* @lucene.experimental*/public final class ByteArrayDataInput extends DataInput {@@ -80,7 +77,6 @@ public final class ByteArrayDataInput extends DataInput {public void skipBytes(int count) {pos += count;- assert pos <= limit;}@Override@@ -90,14 +86,12 @@ public final class ByteArrayDataInput extends DataInput {@Overridepublic int readInt() {- assert pos+4 <= limit;return ((bytes[pos++] & 0xFF) << 24) | ((bytes[pos++] & 0xFF) << 16)| ((bytes[pos++] & 0xFF) << 8) | (bytes[pos++] & 0xFF);}@Overridepublic 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 @@ public final class ByteArrayDataInput extends DataInput {@Overridepublic 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 @@ public final class ByteArrayDataInput extends DataInput {@Overridepublic 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 @@ public final class ByteArrayDataInput extends DataInput {// NOTE: AIOOBE not EOF if you read too much@Overridepublic byte readByte() {- assert checkBounds();return bytes[pos++];}// NOTE: AIOOBE not EOF if you read too much@Overridepublic 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;- }}