Browse Source

Micro-optimize reuseDeltaFor in PackWriter

This switch is called mostly for OBJ_TREE and OBJ_BLOB types, which
typically make up 66% of the objects in a repository. Simplify the
test for these common types by testing for the one bit they have in
common and returning early.

Object type 5 is currently undefined. In the old code it would hit
the default and return true. In the new code it will match the early
case and also return true. In either implementation 5 should never show
up as it is not a valid type known to Git.

Object type 6 OFS_DELTA is not permitted to be supplied here.
Object type 7 REF_DELTA is not permitted to be supplied here.

Change-Id: I0ede8acee928bb3e73c744450863942064864e9c
stable-3.0
Shawn Pearce 12 years ago
parent
commit
01a0699acc
  1. 14
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

14
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -2020,19 +2020,15 @@ public class PackWriter {
} }
private boolean reuseDeltaFor(ObjectToPack otp) { private boolean reuseDeltaFor(ObjectToPack otp) {
switch (otp.getType()) { int type = otp.getType();
case Constants.OBJ_COMMIT: if ((type & 2) != 0) // OBJ_TREE(2) or OBJ_BLOB(3)
return reuseDeltaCommits;
case Constants.OBJ_TREE:
return true;
case Constants.OBJ_BLOB:
return true; return true;
case Constants.OBJ_TAG: if (type == OBJ_COMMIT)
return reuseDeltaCommits;
if (type == OBJ_TAG)
return false; return false;
default:
return true; return true;
} }
}
/** Summary of how PackWriter created the pack. */ /** Summary of how PackWriter created the pack. */
public static class Statistics { public static class Statistics {

Loading…
Cancel
Save