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() {
|
private AbstractTreeIterator fastMin() {
|
||||||
allTreesNamesMatchFastMinRef = true;
|
int i = getFirstNonEofTreeIndex();
|
||||||
|
if (i == -1) {
|
||||||
int i = 0;
|
// All trees reached the end.
|
||||||
|
allTreesNamesMatchFastMinRef = true;
|
||||||
|
return trees[trees.length - 1];
|
||||||
|
}
|
||||||
AbstractTreeIterator minRef = trees[i];
|
AbstractTreeIterator minRef = trees[i];
|
||||||
while (minRef.eof() && ++i < trees.length)
|
allTreesNamesMatchFastMinRef = true;
|
||||||
minRef = trees[i];
|
|
||||||
if (minRef.eof())
|
|
||||||
return minRef;
|
|
||||||
|
|
||||||
boolean hasConflict = false;
|
boolean hasConflict = false;
|
||||||
minRef.matches = minRef;
|
minRef.matches = minRef;
|
||||||
while (++i < trees.length) {
|
while (++i < trees.length) {
|
||||||
|
@ -180,6 +179,15 @@ && nameEqual(minRef, t)) {
|
||||||
return minRef;
|
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,
|
private static boolean nameEqual(final AbstractTreeIterator a,
|
||||||
final AbstractTreeIterator b) {
|
final AbstractTreeIterator b) {
|
||||||
return a.pathCompare(b, TREE_MODE) == 0;
|
return a.pathCompare(b, TREE_MODE) == 0;
|
||||||
|
|
Loading…
Reference in New Issue