crucial performance optimization
This commit is contained in:
parent
95cda79ef1
commit
be303f2e57
@ -108,14 +108,13 @@ public final class BinaryHeapOpenSet implements IOpenSet {
|
|||||||
int smallerChild = 2;
|
int smallerChild = 2;
|
||||||
double cost = val.combinedCost;
|
double cost = val.combinedCost;
|
||||||
do {
|
do {
|
||||||
int right = smallerChild + 1;
|
|
||||||
PathNode smallerChildNode = array[smallerChild];
|
PathNode smallerChildNode = array[smallerChild];
|
||||||
double smallerChildCost = smallerChildNode.combinedCost;
|
double smallerChildCost = smallerChildNode.combinedCost;
|
||||||
if (right <= size) {
|
if (smallerChild < size) {
|
||||||
PathNode rightChildNode = array[right];
|
PathNode rightChildNode = array[smallerChild + 1];
|
||||||
double rightChildCost = rightChildNode.combinedCost;
|
double rightChildCost = rightChildNode.combinedCost;
|
||||||
if (smallerChildCost > rightChildCost) {
|
if (smallerChildCost > rightChildCost) {
|
||||||
smallerChild = right;
|
smallerChild++;
|
||||||
smallerChildCost = rightChildCost;
|
smallerChildCost = rightChildCost;
|
||||||
smallerChildNode = rightChildNode;
|
smallerChildNode = rightChildNode;
|
||||||
}
|
}
|
||||||
@ -128,8 +127,7 @@ public final class BinaryHeapOpenSet implements IOpenSet {
|
|||||||
val.heapPosition = smallerChild;
|
val.heapPosition = smallerChild;
|
||||||
smallerChildNode.heapPosition = index;
|
smallerChildNode.heapPosition = index;
|
||||||
index = smallerChild;
|
index = smallerChild;
|
||||||
smallerChild = index << 1;
|
} while ((smallerChild <<= 1) <= size);
|
||||||
} while (smallerChild <= size);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user