Refactor NameConflictTreeWalk.fastMin method
Change-Id: Iac2e6f615463e18ddf788e6ddfe15ef023cac977
This commit is contained in:
parent
5af93628d4
commit
b544da795b
|
@ -118,15 +118,14 @@ AbstractTreeIterator min() throws CorruptObjectException {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -180,6 +179,15 @@ && nameEqual(minRef, t)) {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue