From fd1ee636a29638e44a3f8c09df846f9ac540c6cf Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 3 Nov 2015 22:33:05 -0800 Subject: [PATCH] Use .addObject and .or instead of .add in AddToBitmapFilter This is the caller that the BitmapBuilder.add method was designed around. Moving away from .add makes it more verbose but hopefully clearer. Change-Id: I57b1d7c1dc8fb800b242b76c606922b5aa36b9b2 --- .../storage/pack/PackWriterBitmapWalker.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 4a7585a9d..01aa93255 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 @@ -167,9 +167,17 @@ final class PackWriterBitmapWalker { @Override public final boolean include(RevWalk walker, RevCommit cmit) { - if (bitmap.add(cmit, Constants.OBJ_COMMIT)) { + Bitmap visitedBitmap; + + if (bitmap.contains(cmit)) { + // already included + } else if ((visitedBitmap = bitmap.getBitmapIndex().getBitmap(cmit)) != null) { + bitmap.or(visitedBitmap); + } else { + bitmap.addObject(cmit, Constants.OBJ_COMMIT); return true; } + for (RevCommit p : cmit.getParents()) { p.add(RevFlag.SEEN); } @@ -212,9 +220,17 @@ final class PackWriterBitmapWalker { @Override public final boolean include(RevWalk walker, RevCommit cmit) { - if (!seen.contains(cmit) && bitmap.add(cmit, Constants.OBJ_COMMIT)) { + Bitmap visitedBitmap; + + if (seen.contains(cmit) || bitmap.contains(cmit)) { + // already seen or included + } else if ((visitedBitmap = bitmap.getBitmapIndex().getBitmap(cmit)) != null) { + bitmap.or(visitedBitmap); + } else { + bitmap.addObject(cmit, Constants.OBJ_COMMIT); return true; } + for (RevCommit p : cmit.getParents()) { p.add(RevFlag.SEEN); }