summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-04-05 09:42:29 -0700
committerShawn Pearce <spearce@spearce.org>2013-04-05 09:43:02 -0700
commit01a0699acc09bc10646411bdd7cd1cf8004f7d65 (patch)
treea74c4a8bcc3273a40bb1657d8c2f3cf78e7d4757 /org.eclipse.jgit
parent8e83c36e277aa79d4c06f4a30181b4457af21963 (diff)
downloadjgit-01a0699acc09bc10646411bdd7cd1cf8004f7d65.tar.gz
jgit-01a0699acc09bc10646411bdd7cd1cf8004f7d65.zip
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
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index feb5bbc836..34bf0eb16b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -2020,18 +2020,14 @@ public class PackWriter {
}
private boolean reuseDeltaFor(ObjectToPack otp) {
- switch (otp.getType()) {
- case Constants.OBJ_COMMIT:
- return reuseDeltaCommits;
- case Constants.OBJ_TREE:
- return true;
- case Constants.OBJ_BLOB:
+ int type = otp.getType();
+ if ((type & 2) != 0) // OBJ_TREE(2) or OBJ_BLOB(3)
return true;
- case Constants.OBJ_TAG:
+ if (type == OBJ_COMMIT)
+ return reuseDeltaCommits;
+ if (type == OBJ_TAG)
return false;
- default:
- return true;
- }
+ return true;
}
/** Summary of how PackWriter created the pack. */