]> source.dussan.org Git - jgit.git/commitdiff
Reset ObjectWalker when it starts a new walk 52/96352/2
authorZhen Chen <czhen@google.com>
Wed, 3 May 2017 21:56:40 +0000 (14:56 -0700)
committerZhen Chen <czhen@google.com>
Wed, 3 May 2017 22:02:33 +0000 (15:02 -0700)
The ObjectWalker in PackWriterBitmapWalker needs to be reset whenever it
starts a new walk. Move this responsibility from the caller to the
method when the new walk starts.

Change-Id: Ib66003be1b5bdc80f46b9bbbb17d45e616714912
Signed-off-by: Zhen Chen <czhen@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

index 93dbee3e797495a9b90c3b3e6ff6dcf0488b2f2c..8810a9f60879b713abab9de5430af2b5b82fa842 100644 (file)
@@ -1874,7 +1874,6 @@ public class PackWriter implements AutoCloseable {
                        throws MissingObjectException, IncorrectObjectTypeException,
                        IOException {
                BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true);
-               bitmapWalker.reset();
                BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap,
                                false);
                BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);
@@ -2079,11 +2078,9 @@ public class PackWriter implements AutoCloseable {
                PackWriterBitmapWalker walker = bitmapPreparer.newBitmapWalker();
                AnyObjectId last = null;
                for (PackWriterBitmapPreparer.BitmapCommit cmit : selectedCommits) {
-                       if (cmit.isReuseWalker())
-                               walker.reset();
-                       else
+                       if (!cmit.isReuseWalker()) {
                                walker = bitmapPreparer.newBitmapWalker();
-
+                       }
                        BitmapBuilder bitmap = walker.findObjects(
                                        Collections.singleton(cmit), null, false);
 
index 34762495cfe1289082e46ebdfe96587d19b6890e..a5c3b71eb2c6a4db0f5f3b03753b9d7f4a6dd383 100644 (file)
@@ -84,7 +84,8 @@ final class PackWriterBitmapWalker {
                return countOfBitmapIndexMisses;
        }
 
-       BitmapBuilder findObjects(Iterable<? extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissing)
+       BitmapBuilder findObjects(Iterable<? extends ObjectId> start, BitmapBuilder seen,
+                       boolean ignoreMissing)
                        throws MissingObjectException, IncorrectObjectTypeException,
                                   IOException {
                if (!ignoreMissing) {
@@ -132,9 +133,11 @@ final class PackWriterBitmapWalker {
                return result;
        }
 
-       private BitmapBuilder findObjectsWalk(Iterable<? extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissingStart)
+       private BitmapBuilder findObjectsWalk(Iterable<? extends ObjectId> start, BitmapBuilder seen,
+                       boolean ignoreMissingStart)
                        throws MissingObjectException, IncorrectObjectTypeException,
                        IOException {
+               walker.reset();
                final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();
 
                for (ObjectId obj : start) {
@@ -189,10 +192,6 @@ final class PackWriterBitmapWalker {
                return bitmapResult;
        }
 
-       void reset() {
-               walker.reset();
-       }
-
        /**
         * A RevFilter that adds the visited commits to {@code bitmap} as a side
         * effect.