Browse Source

Decrease indentation in setupTipCommitBitmaps

Avoid leaving the reader in suspense by handling the unusual
(!RevCommit) case first.  As a nice side effect, there is less nesting
to keep track of in the rest of the loop body.

No functional change intended.

Change-Id: I1580de444fccde08070f696218c12041151a924a
stable-4.2
Jonathan Nieder 9 years ago
parent
commit
7c98c86ef7
  1. 18
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

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

@ -339,9 +339,11 @@ class PackWriterBitmapPreparer {
if ((entry.getFlags() & FLAG_REUSE) != FLAG_REUSE) {
continue;
}
RevObject ro = rw.peel(rw.parseAny(entry));
if (ro instanceof RevCommit) {
if (!(ro instanceof RevCommit)) {
continue;
}
RevCommit rc = (RevCommit) ro;
reuseCommits.add(new BitmapCommit(rc, false, entry.getFlags()));
rw.markUninteresting(rc);
@ -351,7 +353,6 @@ class PackWriterBitmapPreparer {
Constants.OBJ_COMMIT).trim();
reuse.add(rc, Constants.OBJ_COMMIT);
}
}
// Add branch tips that are not represented in old bitmap indices. Set
// up the RevWalk to walk the new commits not in the old packs.
@ -360,7 +361,10 @@ class PackWriterBitmapPreparer {
Set<RevCommit> peeledWant = new HashSet<RevCommit>(want.size());
for (AnyObjectId objectId : want) {
RevObject ro = rw.peel(rw.parseAny(objectId));
if (ro instanceof RevCommit && !reuse.contains(ro)) {
if (!(ro instanceof RevCommit) || reuse.contains(ro)) {
continue;
}
RevCommit rc = (RevCommit) ro;
peeledWant.add(rc);
rw.markStart(rc);
@ -370,7 +374,6 @@ class PackWriterBitmapPreparer {
bitmap.add(rc, Constants.OBJ_COMMIT);
tipCommitBitmaps.add(new BitmapBuilderEntry(rc, bitmap));
}
}
// Create a list of commits in reverse order (older to newer).
// For each branch that contains the commit, mark its parents as being
@ -382,12 +385,13 @@ class PackWriterBitmapPreparer {
commits[--pos] = rc;
for (BitmapBuilderEntry entry : tipCommitBitmaps) {
BitmapBuilder bitmap = entry.getBuilder();
if (bitmap.contains(rc)) {
if (!bitmap.contains(rc)) {
continue;
}
for (RevCommit c : rc.getParents()) {
bitmap.add(c, Constants.OBJ_COMMIT);
}
}
}
pm.update(1);
}

Loading…
Cancel
Save