Signed-off-by: Marek Zawirski <marek.zawirski@xxxxxxxxx> --- .../src/org/spearce/jgit/lib/PackIndexV2.java | 23 +++++++++++++------- 1 files changed, 15 insertions(+), 8 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV2.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV2.java index ae70f11..a0b9827 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV2.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV2.java @@ -153,6 +153,20 @@ class PackIndexV2 extends PackIndex { @Override long findOffset(final AnyObjectId objId) { final int levelOne = objId.getFirstByte(); + final int levelTwo = binarySearchLevelTwo(objId, levelOne); + if (levelTwo == -1) + return -1; + final long p = NB.decodeUInt32(offset32[levelOne], levelTwo << 2); + if ((p & IS_O64) != 0) + return NB.decodeUInt64(offset64, (8 * (int) (p & ~IS_O64))); + return p; + } + + public Iterator<MutableEntry> iterator() { + return new EntriesIteratorV2(); + } + + private int binarySearchLevelTwo(final AnyObjectId objId, final int levelOne) { final int[] data = names[levelOne]; int high = offset32[levelOne].length >> 2; if (high == 0) @@ -167,20 +181,13 @@ class PackIndexV2 extends PackIndex { if (cmp < 0) high = mid; else if (cmp == 0) { - final long p = NB.decodeUInt32(offset32[levelOne], mid4); - if ((p & IS_O64) != 0) - return NB.decodeUInt64(offset64, (8 * (int) (p & ~IS_O64))); - return p; + return mid; } else low = mid + 1; } while (low < high); return -1; } - public Iterator<MutableEntry> iterator() { - return new EntriesIteratorV2(); - } - private class EntriesIteratorV2 extends EntriesIterator { private int levelOne; -- 1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html