Browse Source

Reset ObjectWalker when it starts a new walk

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>
stable-4.8
Zhen Chen 8 years ago
parent
commit
8f7d0a4fbe
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  2. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

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

@ -1874,7 +1874,6 @@ public class PackWriter implements AutoCloseable {
throws MissingObjectException, IncorrectObjectTypeException, throws MissingObjectException, IncorrectObjectTypeException,
IOException { IOException {
BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true); BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true);
bitmapWalker.reset();
BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap, BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap,
false); false);
BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap); BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);
@ -2079,11 +2078,9 @@ public class PackWriter implements AutoCloseable {
PackWriterBitmapWalker walker = bitmapPreparer.newBitmapWalker(); PackWriterBitmapWalker walker = bitmapPreparer.newBitmapWalker();
AnyObjectId last = null; AnyObjectId last = null;
for (PackWriterBitmapPreparer.BitmapCommit cmit : selectedCommits) { for (PackWriterBitmapPreparer.BitmapCommit cmit : selectedCommits) {
if (cmit.isReuseWalker()) if (!cmit.isReuseWalker()) {
walker.reset();
else
walker = bitmapPreparer.newBitmapWalker(); walker = bitmapPreparer.newBitmapWalker();
}
BitmapBuilder bitmap = walker.findObjects( BitmapBuilder bitmap = walker.findObjects(
Collections.singleton(cmit), null, false); Collections.singleton(cmit), null, false);

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

@ -84,7 +84,8 @@ final class PackWriterBitmapWalker {
return countOfBitmapIndexMisses; 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, throws MissingObjectException, IncorrectObjectTypeException,
IOException { IOException {
if (!ignoreMissing) { if (!ignoreMissing) {
@ -132,9 +133,11 @@ final class PackWriterBitmapWalker {
return result; 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, throws MissingObjectException, IncorrectObjectTypeException,
IOException { IOException {
walker.reset();
final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder(); final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();
for (ObjectId obj : start) { for (ObjectId obj : start) {
@ -189,10 +192,6 @@ final class PackWriterBitmapWalker {
return bitmapResult; return bitmapResult;
} }
void reset() {
walker.reset();
}
/** /**
* A RevFilter that adds the visited commits to {@code bitmap} as a side * A RevFilter that adds the visited commits to {@code bitmap} as a side
* effect. * effect.

Loading…
Cancel
Save