From b4a5630c10a94a150d5aa8f2a0ef4d6e2189b002 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Mar 2013 09:10:44 +0100 Subject: [PATCH] MatPoints: use std::set instead of std::map Much more efficient. Also folds the find() and insert() calls into just insert(). --- src/Engine/Task/Ordered/MatPoints.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Engine/Task/Ordered/MatPoints.cpp b/src/Engine/Task/Ordered/MatPoints.cpp index 9cb7e43d7..fbad66307 100644 --- a/src/Engine/Task/Ordered/MatPoints.cpp +++ b/src/Engine/Task/Ordered/MatPoints.cpp @@ -30,7 +30,7 @@ Copyright_License { #include "Geo/GeoPoint.hpp" #include "Math/fixed.hpp" -#include +#include /** * Class to build vector from visited waypoints. @@ -53,7 +53,7 @@ private: * a temp map used to dedupe mat points when * we're adding via closest first */ - std::map dedupe; + std::set dedupe; const AbstractTaskFactory& factory; @@ -65,8 +65,7 @@ private: void AddUnique(const Waypoint &wp) { const unsigned key = wp.id; - if (dedupe.find(key) == dedupe.end()) { - dedupe[key] = 0; + if (dedupe.insert(key).second) { OrderedTaskPoint *tp = factory.CreateIntermediate(wp); vector.push_back(tp); } -- 2.11.4.GIT