]> source.dussan.org Git - jgit.git/commitdiff
PackWriter: Only search for base objects on thin packs 77/3977/1
authorShawn O. Pearce <spearce@spearce.org>
Mon, 8 Aug 2011 15:50:13 +0000 (08:50 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 8 Aug 2011 22:10:11 +0000 (15:10 -0700)
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>
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java

index 3007b809c29f2ab53178d0aef51dceeb16d75c3b..2153ad5d3fb632519b403d9ca94365439c0b3ce4 100644 (file)
@@ -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)