From f4f79f47bd769a91e6e25dc4603b57095a1a4521 Mon Sep 17 00:00:00 2001 From: sakagushi Date: Thu, 6 Feb 2014 03:57:17 -0200 Subject: [PATCH] Optimizations in Map::findPath --- src/client/map.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/client/map.cpp b/src/client/map.cpp index b410344b..41c86874 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -798,13 +798,11 @@ std::tuple, Otc::PathFindResult> Map::findPath(const std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; }); auto end = std::unique(searchList.begin(), searchList.end()); - searchList.resize(std::distance(searchList.begin(), end)); currentNode->evaluated = true; currentNode = nullptr; - while(!searchList.empty() && !currentNode) { - Node *node = searchList.front(); - searchList.pop_front(); + for (auto begin = searchList.begin(); begin != end && !currentNode; ++begin) { + Node *node = *begin; if(!node->evaluated) currentNode = node;