File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
test/lib/jdk/test/lib/format Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -301,10 +301,11 @@ public int getElementLength() {
301301 * Finds and returns the first mismatch index in another codec
302302 *
303303 * @param another a codec mismatch with whom is to be found
304- * @return the first mismatched element's index
304+ * @return the first mismatched element's index or -1 if arrays are identical
305305 */
306306 public int findMismatchIndex (ArrayCodec <E > another ) {
307- for (int result = 0 ; (source .size () > result ) && (another .source .size () > result ); result ++) {
307+ int result = 0 ;
308+ while ((source .size () > result ) && (another .source .size () > result )) {
308309 Object first = source .get (result );
309310 Object second = another .source .get (result );
310311
@@ -320,9 +321,12 @@ public int findMismatchIndex(ArrayCodec<E> another) {
320321 return result ;
321322 }
322323
324+ result ++;
323325 }
324326
325- return 0 ;
327+ return source .size () != another .source .size ()
328+ ? result // Lengths are different, but the shorter arrays is a preffix to the longer array.
329+ : -1 ; // Arrays are identical, there's no mismatch index
326330 }
327331
328332 /**
You can’t perform that action at this time.
0 commit comments