diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-26 19:46:31 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-11-15 17:12:30 -0800 |
commit | cb85f7be8b45572c5b35d794690aa92fe5339089 (patch) | |
tree | 9b5a2c9ae1819bd2e7ba3af8d301a27dfb0eee82 | |
parent | 1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd (diff) | |
download | jgit-cb85f7be8b45572c5b35d794690aa92fe5339089.tar.gz jgit-cb85f7be8b45572c5b35d794690aa92fe5339089.zip |
TopoSortGenerator: simplify first-parent handling
Change-Id: I74b40f1a2f81911c1d5ac5ae93b4a160fccf8f73
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TopoSortGenerator.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TopoSortGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TopoSortGenerator.java index a2c9ef6da4..e0325c29f9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TopoSortGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TopoSortGenerator.java @@ -80,11 +80,11 @@ class TopoSortGenerator extends Generator { if (c == null) { break; } - for (int i = 0; i < c.parents.length; i++) { - if (firstParent && i > 0) { + for (RevCommit p : c.parents) { + p.inDegree++; + if (firstParent) { break; } - c.parents[i].inDegree++; } pending.add(c); } @@ -119,11 +119,7 @@ class TopoSortGenerator extends Generator { // All of our children have already produced, // so it is OK for us to produce now as well. // - for (int i = 0; i < c.parents.length; i++) { - if (firstParent && i > 0) { - break; - } - RevCommit p = c.parents[i]; + for (RevCommit p : c.parents) { if (--p.inDegree == 0 && (p.flags & TOPO_DELAY) != 0) { // This parent tried to come before us, but we are // his last child. unpop the parent so it goes right @@ -132,6 +128,9 @@ class TopoSortGenerator extends Generator { p.flags &= ~TOPO_DELAY; pending.unpop(p); } + if (firstParent) { + break; + } } return c; } |