summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2015-11-03 11:42:53 -0800
committerJonathan Nieder <jrn@google.com>2015-11-03 11:42:53 -0800
commit7c98c86ef7cbcf782c05d8c6c766538024225d02 (patch)
tree4b9ed78c30866d24f06d4aaca39551663c490482
parent8473bc4f8d2d69ca8aa3b4889660ed17d08f2270 (diff)
downloadjgit-7c98c86ef7cbcf782c05d8c6c766538024225d02.tar.gz
jgit-7c98c86ef7cbcf782c05d8c6c766538024225d02.zip
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
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java50
1 files changed, 27 insertions, 23 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
index a58caa924b..e244de790b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
@@ -339,18 +339,19 @@ class PackWriterBitmapPreparer {
if ((entry.getFlags() & FLAG_REUSE) != FLAG_REUSE) {
continue;
}
-
RevObject ro = rw.peel(rw.parseAny(entry));
- if (ro instanceof RevCommit) {
- RevCommit rc = (RevCommit) ro;
- reuseCommits.add(new BitmapCommit(rc, false, entry.getFlags()));
- rw.markUninteresting(rc);
- // PackBitmapIndexRemapper.ofObjectType() ties the underlying
- // bitmap in the old pack into the new bitmap builder.
- bitmapRemapper.ofObjectType(bitmapRemapper.getBitmap(rc),
- Constants.OBJ_COMMIT).trim();
- reuse.add(rc, Constants.OBJ_COMMIT);
+ if (!(ro instanceof RevCommit)) {
+ continue;
}
+
+ RevCommit rc = (RevCommit) ro;
+ reuseCommits.add(new BitmapCommit(rc, false, entry.getFlags()));
+ rw.markUninteresting(rc);
+ // PackBitmapIndexRemapper.ofObjectType() ties the underlying
+ // bitmap in the old pack into the new bitmap builder.
+ bitmapRemapper.ofObjectType(bitmapRemapper.getBitmap(rc),
+ Constants.OBJ_COMMIT).trim();
+ reuse.add(rc, Constants.OBJ_COMMIT);
}
// Add branch tips that are not represented in old bitmap indices. Set
@@ -360,16 +361,18 @@ 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)) {
- RevCommit rc = (RevCommit) ro;
- peeledWant.add(rc);
- rw.markStart(rc);
-
- BitmapBuilder bitmap = commitBitmapIndex.newBitmapBuilder();
- bitmap.or(reuse);
- bitmap.add(rc, Constants.OBJ_COMMIT);
- tipCommitBitmaps.add(new BitmapBuilderEntry(rc, bitmap));
+ if (!(ro instanceof RevCommit) || reuse.contains(ro)) {
+ continue;
}
+
+ RevCommit rc = (RevCommit) ro;
+ peeledWant.add(rc);
+ rw.markStart(rc);
+
+ BitmapBuilder bitmap = commitBitmapIndex.newBitmapBuilder();
+ bitmap.or(reuse);
+ bitmap.add(rc, Constants.OBJ_COMMIT);
+ tipCommitBitmaps.add(new BitmapBuilderEntry(rc, bitmap));
}
// Create a list of commits in reverse order (older to newer).
@@ -382,10 +385,11 @@ class PackWriterBitmapPreparer {
commits[--pos] = rc;
for (BitmapBuilderEntry entry : tipCommitBitmaps) {
BitmapBuilder bitmap = entry.getBuilder();
- if (bitmap.contains(rc)) {
- for (RevCommit c : rc.getParents()) {
- bitmap.add(c, Constants.OBJ_COMMIT);
- }
+ if (!bitmap.contains(rc)) {
+ continue;
+ }
+ for (RevCommit c : rc.getParents()) {
+ bitmap.add(c, Constants.OBJ_COMMIT);
}
}
pm.update(1);