Browse Source

Inline PackWriterBitmapWalker.newRevFilter into callers

Instead of using the newRevFilter helper, call the appropriate
RevFilter constructor directly.  This means one less hop to find
documentation about what the RevFilter will do.

Change-Id: Ida6ff1c0457a47a1bd1e4ed0fd1dd42a616d214f
stable-4.2
Jonathan Nieder 9 years ago
parent
commit
e87f0cd866
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
  2. 19
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

@ -63,6 +63,7 @@ import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndex; import org.eclipse.jgit.internal.storage.file.PackBitmapIndex;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder; import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexRemapper; import org.eclipse.jgit.internal.storage.file.PackBitmapIndexRemapper;
import org.eclipse.jgit.internal.storage.pack.PackWriterBitmapWalker.AddUnseenToBitmapFilter;
import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
@ -262,7 +263,7 @@ class PackWriterBitmapPreparer {
BitmapBuilder fullBitmap = commitBitmapIndex.newBitmapBuilder(); BitmapBuilder fullBitmap = commitBitmapIndex.newBitmapBuilder();
rw.reset(); rw.reset();
rw.markStart(c); rw.markStart(c);
rw.setRevFilter(PackWriterBitmapWalker.newRevFilter( rw.setRevFilter(new AddUnseenToBitmapFilter(
selectionHelper.reusedCommitsBitmap, fullBitmap)); selectionHelper.reusedCommitsBitmap, fullBitmap));
while (rw.next() != null) { while (rw.next() != null) {

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

@ -110,8 +110,12 @@ final class PackWriterBitmapWalker {
} }
if (marked) { if (marked) {
RevFilter filter = newRevFilter(seen, bitmapResult); if (seen == null) {
walker.setRevFilter(filter); walker.setRevFilter(new AddToBitmapFilter(bitmapResult));
} else {
walker.setRevFilter(
new AddUnseenToBitmapFilter(seen, bitmapResult));
}
while (walker.next() != null) { while (walker.next() != null) {
// Iterate through all of the commits. The BitmapRevFilter does // Iterate through all of the commits. The BitmapRevFilter does
@ -141,13 +145,6 @@ final class PackWriterBitmapWalker {
walker.reset(); walker.reset();
} }
static RevFilter newRevFilter(BitmapBuilder seen, BitmapBuilder bitmapResult) {
if (seen != null) {
return new AddUnseenToBitmapFilter(seen, bitmapResult);
}
return new AddToBitmapFilter(bitmapResult);
}
/** /**
* 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.
@ -158,7 +155,7 @@ final class PackWriterBitmapWalker {
* have to visit its ancestors. This ensures the walk is very short if * have to visit its ancestors. This ensures the walk is very short if
* there is good bitmap coverage. * there is good bitmap coverage.
*/ */
private static class AddToBitmapFilter extends RevFilter { static class AddToBitmapFilter extends RevFilter {
private final BitmapBuilder bitmap; private final BitmapBuilder bitmap;
AddToBitmapFilter(BitmapBuilder bitmap) { AddToBitmapFilter(BitmapBuilder bitmap) {
@ -209,7 +206,7 @@ final class PackWriterBitmapWalker {
* encountered, that commit and its parents will be marked with the SEEN * encountered, that commit and its parents will be marked with the SEEN
* flag to prevent the walk from visiting its ancestors. * flag to prevent the walk from visiting its ancestors.
*/ */
private static class AddUnseenToBitmapFilter extends RevFilter { static class AddUnseenToBitmapFilter extends RevFilter {
private final BitmapBuilder seen; private final BitmapBuilder seen;
private final BitmapBuilder bitmap; private final BitmapBuilder bitmap;

Loading…
Cancel
Save