< prev index next >

src/java.base/share/classes/jdk/internal/util/ArraysSupport.java

Print this page

        

*** 163,172 **** --- 163,174 ---- public static int mismatch(boolean[] a, boolean[] b, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 7) { i = vectorizedMismatch( a, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, b, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE);
*** 183,192 **** --- 185,196 ---- public static int mismatch(boolean[] a, int aFromIndex, boolean[] b, int bFromIndex, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 7) { int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex; int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex; i = vectorizedMismatch( a, aOffset,
*** 225,234 **** --- 229,240 ---- // ISSUE: defer to index receiving methods if performance is good // assert length <= a.length // assert length <= b.length int i = 0; + if (a[i] != b[i]) + return i; if (length > 7) { i = vectorizedMismatch( a, Unsafe.ARRAY_BYTE_BASE_OFFSET, b, Unsafe.ARRAY_BYTE_BASE_OFFSET, length, LOG2_ARRAY_BYTE_INDEX_SCALE);
*** 272,281 **** --- 278,289 ---- // assert 0 <= bFromIndex < b.length // assert 0 <= bFromIndex + length <= b.length // assert length >= 0 int i = 0; + if (a[i] != b[i]) + return i; if (length > 7) { int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex; int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex; i = vectorizedMismatch( a, aOffset,
*** 297,306 **** --- 305,316 ---- public static int mismatch(char[] a, char[] b, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 3) { i = vectorizedMismatch( a, Unsafe.ARRAY_CHAR_BASE_OFFSET, b, Unsafe.ARRAY_CHAR_BASE_OFFSET, length, LOG2_ARRAY_CHAR_INDEX_SCALE);
*** 317,326 **** --- 327,338 ---- public static int mismatch(char[] a, int aFromIndex, char[] b, int bFromIndex, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 3) { int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); int bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); i = vectorizedMismatch( a, aOffset,
*** 342,351 **** --- 354,365 ---- public static int mismatch(short[] a, short[] b, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 3) { i = vectorizedMismatch( a, Unsafe.ARRAY_SHORT_BASE_OFFSET, b, Unsafe.ARRAY_SHORT_BASE_OFFSET, length, LOG2_ARRAY_SHORT_INDEX_SCALE);
*** 362,371 **** --- 376,387 ---- public static int mismatch(short[] a, int aFromIndex, short[] b, int bFromIndex, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 3) { int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); int bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset,
*** 387,396 **** --- 403,414 ---- public static int mismatch(int[] a, int[] b, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 1) { i = vectorizedMismatch( a, Unsafe.ARRAY_INT_BASE_OFFSET, b, Unsafe.ARRAY_INT_BASE_OFFSET, length, LOG2_ARRAY_INT_INDEX_SCALE);
*** 407,416 **** --- 425,436 ---- public static int mismatch(int[] a, int aFromIndex, int[] b, int bFromIndex, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 1) { int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); int bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset,
*** 438,447 **** --- 458,469 ---- public static int mismatch(float[] a, int aFromIndex, float[] b, int bFromIndex, int length) { int i = 0; + if (a[i] != b[i]) + return i; if (length > 1) { int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); int bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset,
< prev index next >