diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-12-01 09:59:55 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-12-01 09:59:55 -0800 |
commit | e0a9961b781db240d71190dece2fd2c70ea79765 (patch) | |
tree | 2630b113d774b4cafb0dceac6ef828f388194bcd | |
parent | d29b5db695225ed9629b028f99070bd182320b0f (diff) | |
download | jgit-e0a9961b781db240d71190dece2fd2c70ea79765.tar.gz jgit-e0a9961b781db240d71190dece2fd2c70ea79765.zip |
Avoid unnecessary decoding of length in PackFile
If the object type is a whole object and all we want is the type,
there is no need to skip the length header. The type is already known
and can be returned as-is. Instead skip the length header only for
the two delta formats, where the delta base must itself be scanned.
Change-Id: I87029258e88924b3e5850bdd6c9006a366191d10
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java index 54af0ff838..8db5c1bd55 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java @@ -758,9 +758,6 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { readFully(pos, ib, 0, 20, curs); int c = ib[0] & 0xff; final int type = (c >> 4) & 7; - int p = 1; - while ((c & 0x80) != 0) - c = ib[p++] & 0xff; switch (type) { case Constants.OBJ_COMMIT: @@ -770,6 +767,9 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { return type; case Constants.OBJ_OFS_DELTA: { + int p = 1; + while ((c & 0x80) != 0) + c = ib[p++] & 0xff; c = ib[p++] & 0xff; long ofs = c & 127; while ((c & 128) != 0) { @@ -783,6 +783,9 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { } case Constants.OBJ_REF_DELTA: { + int p = 1; + while ((c & 0x80) != 0) + c = ib[p++] & 0xff; readFully(pos + p, ib, 0, 20, curs); pos = findDeltaBase(ObjectId.fromRaw(ib)); continue; |