From 8f7d0a4fbe8862e71d900b0585c97407037ef9a5 Mon Sep 17 00:00:00 2001 From: Zhen Chen Date: Wed, 3 May 2017 14:56:40 -0700 Subject: [PATCH] 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 --- .../jgit/internal/storage/pack/PackWriter.java | 7 ++----- .../internal/storage/pack/PackWriterBitmapWalker.java | 11 +++++------ 2 files changed, 7 insertions(+), 11 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 93dbee3e79..8810a9f608 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 @@ -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); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java index 34762495cf..a5c3b71eb2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java @@ -84,7 +84,8 @@ final class PackWriterBitmapWalker { return countOfBitmapIndexMisses; } - BitmapBuilder findObjects(Iterable start, BitmapBuilder seen, boolean ignoreMissing) + BitmapBuilder findObjects(Iterable start, BitmapBuilder seen, + boolean ignoreMissing) throws MissingObjectException, IncorrectObjectTypeException, IOException { if (!ignoreMissing) { @@ -132,9 +133,11 @@ final class PackWriterBitmapWalker { return result; } - private BitmapBuilder findObjectsWalk(Iterable start, BitmapBuilder seen, boolean ignoreMissingStart) + private BitmapBuilder findObjectsWalk(Iterable 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. -- 2.39.5