Optimizations in Map::findPath
This commit is contained in:
parent
ff617c3fab
commit
f4f79f47bd
|
@ -798,13 +798,11 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
||||||
|
|
||||||
std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; });
|
std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; });
|
||||||
auto end = std::unique(searchList.begin(), searchList.end());
|
auto end = std::unique(searchList.begin(), searchList.end());
|
||||||
searchList.resize(std::distance(searchList.begin(), end));
|
|
||||||
|
|
||||||
currentNode->evaluated = true;
|
currentNode->evaluated = true;
|
||||||
currentNode = nullptr;
|
currentNode = nullptr;
|
||||||
while(!searchList.empty() && !currentNode) {
|
for (auto begin = searchList.begin(); begin != end && !currentNode; ++begin) {
|
||||||
Node *node = searchList.front();
|
Node *node = *begin;
|
||||||
searchList.pop_front();
|
|
||||||
|
|
||||||
if(!node->evaluated)
|
if(!node->evaluated)
|
||||||
currentNode = node;
|
currentNode = node;
|
||||||
|
|
Loading…
Reference in New Issue