Improve perf with static lambda function

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
This commit is contained in:
Bensuperpc 2024-06-21 21:51:56 +02:00
parent 82f9877897
commit d3247bbc54
No known key found for this signature in database
GPG Key ID: EED195F75454E328
2 changed files with 3 additions and 3 deletions

View File

@ -196,7 +196,7 @@ Sources and references that I have used to make this library.
* [a-star](https://www.ce.unipr.it/people/medici/a-star.html)$ * [a-star](https://www.ce.unipr.it/people/medici/a-star.html)$
* [A* Search Algorithm](https://yuminlee2.medium.com/a-search-algorithm-42c1a13fcf9f) * [A* Search Algorithm](https://yuminlee2.medium.com/a-search-algorithm-42c1a13fcf9f)
## Bench others astar implementations ## Others astar implementations
The list of others astar implementations that I have benchmarked to compare the performance of my implementation. The list of others astar implementations that I have benchmarked to compare the performance of my implementation.

View File

@ -171,7 +171,7 @@ class AStar final : public AStarVirtual<CoordinateType, enableDebug> {
Node<CoordinateType>* currentNode = nullptr; Node<CoordinateType>* currentNode = nullptr;
auto compareFn = [](const Node<CoordinateType>* a, const Node<CoordinateType>* b) { return a->getTotalCost() > b->getTotalCost(); }; static auto compareFn = [](const Node<CoordinateType>* a, const Node<CoordinateType>* b) { return a->getTotalCost() > b->getTotalCost(); };
std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)> openNodeVecPQueue = std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)> openNodeVecPQueue =
std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)>(compareFn); std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)>(compareFn);
@ -278,7 +278,7 @@ class AStarFast final : public AStarVirtual<CoordinateType, enableDebug> {
Node<CoordinateType>* currentNode = nullptr; Node<CoordinateType>* currentNode = nullptr;
auto compareFn = [](const Node<CoordinateType>* a, const Node<CoordinateType>* b) { return a->getTotalCost() > b->getTotalCost(); }; static auto compareFn = [](const Node<CoordinateType>* a, const Node<CoordinateType>* b) { return a->getTotalCost() > b->getTotalCost(); };
std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)> openNodeVecPQueue = std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)> openNodeVecPQueue =
std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)>(compareFn); std::priority_queue<Node<CoordinateType>*, std::vector<Node<CoordinateType>*>, decltype(compareFn)>(compareFn);
std::unordered_map<Vec2i, Node<CoordinateType>*, Vec2i::hash> openNodeMap; std::unordered_map<Vec2i, Node<CoordinateType>*, Vec2i::hash> openNodeMap;