}
private AbstractTreeIterator fastMin() {
- allTreesNamesMatchFastMinRef = true;
-
- int i = 0;
+ int i = getFirstNonEofTreeIndex();
+ if (i == -1) {
+ // All trees reached the end.
+ allTreesNamesMatchFastMinRef = true;
+ return trees[trees.length - 1];
+ }
AbstractTreeIterator minRef = trees[i];
- while (minRef.eof() && ++i < trees.length)
- minRef = trees[i];
- if (minRef.eof())
- return minRef;
-
+ allTreesNamesMatchFastMinRef = true;
boolean hasConflict = false;
minRef.matches = minRef;
while (++i < trees.length) {
return minRef;
}
+ private int getFirstNonEofTreeIndex() {
+ for (int i = 0; i < trees.length; i++) {
+ if (!trees[i].eof()) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
private static boolean nameEqual(final AbstractTreeIterator a,
final AbstractTreeIterator b) {
return a.pathCompare(b, TREE_MODE) == 0;