Source:
private void ensureOne(Map.Entry<Integer, BitmapDataProvider> e, int currentHigh, int indexOk) { assert indexOk <= sortedHighs.length; final int index; if (indexOk == 0) { if (sortedHighs.length == 0) { index = -1; } else { index = -1; } } else if (indexOk < sortedHighs.length) { index = -indexOk - 1; } else { index = -sortedHighs.length - 1; } assert index == binarySearch(sortedHighs, 0, indexOk, currentHigh); if (index >= 0) { throw new IllegalStateException("Unexpectely found " + currentHigh + " in " + Arrays.toString(sortedHighs) + " strictly before index" + indexOk); } else { int insertionPosition = -index - 1; if (insertionPosition >= sortedHighs.length) { int previousSize = sortedHighs.length; int newSize = Math.min(Integer.MAX_VALUE, sortedHighs.length * 2 + 1); sortedHighs = Arrays.copyOf(sortedHighs, newSize); sortedCumulatedCardinality = Arrays.copyOf(sortedCumulatedCardinality, newSize); Arrays.fill(sortedHighs, previousSize, sortedHighs.length, highestHigh()); Arrays.fill(sortedCumulatedCardinality, previousSize, sortedHighs.length, Long.MAX_VALUE); } sortedHighs[insertionPosition] = currentHigh; final long previousCardinality; if (insertionPosition >= 1) { previousCardinality = sortedCumulatedCardinality[insertionPosition - 1]; } else { previousCardinality = 0; } sortedCumulatedCardinality[insertionPosition] = previousCardinality + e.getValue().getLongCardinality(); if (currentHigh == highestHigh()) { firstHighNotValid = currentHigh; } else { firstHighNotValid = currentHigh + 1; } } }

Target:
private void ensureOne(Map.Entry<Integer, BitmapDataProvider> e, int currentHigh, int indexOk) { assert indexOk <= sortedHighs.length : indexOk + " is bigger than " + sortedHighs.length; final int index; if (indexOk == 0) { if (sortedHighs.length == 0) { index = -1; } else { index = -1; } } else if (indexOk < sortedHighs.length) { index = -indexOk - 1; } else { index = -sortedHighs.length - 1; } assert index == binarySearch(sortedHighs, 0, indexOk, currentHigh) : "Computed " + index + " differs from dummy binary-search index: " + binarySearch(sortedHighs, 0, indexOk, currentHigh); if (index >= 0) { throw new IllegalStateException("Unexpectedly found " + currentHigh + " in " + Arrays.toString(sortedHighs) + " strictly before index" + indexOk); } else { int insertionPosition = -index - 1; if (insertionPosition >= sortedHighs.length) { int previousSize = sortedHighs.length; int newSize = Math.min(Integer.MAX_VALUE, sortedHighs.length * 2 + 1); sortedHighs = Arrays.copyOf(sortedHighs, newSize); sortedCumulatedCardinality = Arrays.copyOf(sortedCumulatedCardinality, newSize); Arrays.fill(sortedHighs, previousSize, sortedHighs.length, highestHigh()); Arrays.fill(sortedCumulatedCardinality, previousSize, sortedHighs.length, Long.MAX_VALUE); } sortedHighs[insertionPosition] = currentHigh; final long previousCardinality; if (insertionPosition >= 1) { previousCardinality = sortedCumulatedCardinality[insertionPosition - 1]; } else { previousCardinality = 0; } sortedCumulatedCardinality[insertionPosition] = previousCardinality + e.getValue().getLongCardinality(); if (currentHigh == highestHigh()) { firstHighNotValid = currentHigh; } else { firstHighNotValid = currentHigh + 1; } } }