summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-08-08 08:50:13 -0700
committerShawn O. Pearce <spearce@spearce.org>2011-08-08 15:10:11 -0700
commit99e6cfb131bb407247acbc8c0a73e7c7cf37ebc2 (patch)
treeac73dd8bf7ebe051bb805dda53b7815476e3af5f
parent489604aaad8ef8d252bf31056db4de01e690fa0b (diff)
downloadjgit-99e6cfb131bb407247acbc8c0a73e7c7cf37ebc2.tar.gz
jgit-99e6cfb131bb407247acbc8c0a73e7c7cf37ebc2.zip
PackWriter: Only search for base objects on thin packs
A non-thin pack does not need to worry about preferred bases, the pack will be self-contained and all required delta base objects will appear within the pack itself. Obtaining the path buffer and length from the ObjectWalk to build the preferred base table is "expensive", so avoid the cost unless a thin pack is being constructed. Change-Id: I16e30cd864f4189d4304e7957a7cd5bdb9e84528 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
index 3007b809c2..2153ad5d3f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
@@ -1437,20 +1437,29 @@ public class PackWriter {
}
commits = null;
- BaseSearch bases = new BaseSearch(countingMonitor, baseTrees, //
- objectsMap, edgeObjects, reader);
- RevObject o;
- while ((o = walker.nextObject()) != null) {
- if (o.has(RevFlag.UNINTERESTING))
- continue;
-
- int pathHash = walker.getPathHashCode();
- byte[] pathBuf = walker.getPathBuffer();
- int pathLen = walker.getPathLength();
+ if (thin && !baseTrees.isEmpty()) {
+ BaseSearch bases = new BaseSearch(countingMonitor, baseTrees, //
+ objectsMap, edgeObjects, reader);
+ RevObject o;
+ while ((o = walker.nextObject()) != null) {
+ if (o.has(RevFlag.UNINTERESTING))
+ continue;
- bases.addBase(o.getType(), pathBuf, pathLen, pathHash);
- addObject(o, pathHash);
- countingMonitor.update(1);
+ int pathHash = walker.getPathHashCode();
+ byte[] pathBuf = walker.getPathBuffer();
+ int pathLen = walker.getPathLength();
+ bases.addBase(o.getType(), pathBuf, pathLen, pathHash);
+ addObject(o, pathHash);
+ countingMonitor.update(1);
+ }
+ } else {
+ RevObject o;
+ while ((o = walker.nextObject()) != null) {
+ if (o.has(RevFlag.UNINTERESTING))
+ continue;
+ addObject(o, walker.getPathHashCode());
+ countingMonitor.update(1);
+ }
}
for (CachedPack pack : cachedPacks)