public int getInstructionIndexAtCodeOffset(int codeOffset, boolean exact) { int index = Arrays.binarySearch(instructionCodeOffsets, codeOffset); if (index < 0) { if (exact) { throw new InvalidInstructionOffset(codeOffset); } else { // This calculation would be incorrect if index was -1 (i.e. insertion point of 0). Luckily, we can // ignore this case, because codeOffset will always be non-negative, and the code offset of the first // instruction will always be 0. return (~index) - 1; } } return index; }
public int getInstructionIndexAtCodeOffset(int codeOffset, boolean exact) { int index = Arrays.binarySearch(instructionCodeOffsets, codeOffset); if (index < 0) { if (exact) { throw new InvalidInstructionOffset(codeOffset); } else { // This calculation would be incorrect if index was -1 (i.e. insertion point of 0). Luckily, we can // ignore this case, because codeOffset will always be non-negative, and the code offset of the first // instruction will always be 0. return (~index) - 1; } } return index; }
public int getInstructionIndexAtCodeOffset(int codeOffset, boolean exact) { int index = Arrays.binarySearch(instructionCodeOffsets, codeOffset); if (index < 0) { if (exact) { throw new InvalidInstructionOffset(codeOffset); } else { // This calculation would be incorrect if index was -1 (i.e. insertion point of 0). Luckily, we can // ignore this case, because codeOffset will always be non-negative, and the code offset of the first // instruction will always be 0. return (~index) - 1; } } return index; }