Skip to content

Commit

Permalink
Improve perf with static lambda function
Browse files Browse the repository at this point in the history
Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
  • Loading branch information
bensuperpc committed Jun 21, 2024
1 parent 82f9877 commit d3247bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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* 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.

Expand Down
4 changes: 2 additions & 2 deletions include/astar/astar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class AStar final : public AStarVirtual<CoordinateType, enableDebug> {

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)>(compareFn);

Expand Down Expand Up @@ -278,7 +278,7 @@ class AStarFast final : public AStarVirtual<CoordinateType, enableDebug> {

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)>(compareFn);
std::unordered_map<Vec2i, Node<CoordinateType>*, Vec2i::hash> openNodeMap;
Expand Down

0 comments on commit d3247bb

Please sign in to comment.