crucial performance optimization

This commit is contained in:
Leijurv 2018-08-29 16:13:14 -07:00
parent 95cda79ef1
commit be303f2e57
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -108,14 +108,13 @@ public final class BinaryHeapOpenSet implements IOpenSet {
int smallerChild = 2;
double cost = val.combinedCost;
do {
int right = smallerChild + 1;
PathNode smallerChildNode = array[smallerChild];
double smallerChildCost = smallerChildNode.combinedCost;
if (right <= size) {
PathNode rightChildNode = array[right];
if (smallerChild < size) {
PathNode rightChildNode = array[smallerChild + 1];
double rightChildCost = rightChildNode.combinedCost;
if (smallerChildCost > rightChildCost) {
smallerChild = right;
smallerChild++;
smallerChildCost = rightChildCost;
smallerChildNode = rightChildNode;
}
@ -128,8 +127,7 @@ public final class BinaryHeapOpenSet implements IOpenSet {
val.heapPosition = smallerChild;
smallerChildNode.heapPosition = index;
index = smallerChild;
smallerChild = index << 1;
} while (smallerChild <= size);
} while ((smallerChild <<= 1) <= size);
return result;
}
}