From 00d265e3c812516e2a71faed4f352b36f51112e2 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Mon, 3 Jun 2019 10:29:12 +0200 Subject: cmPropertyMap: Use std::unordered_map as container instead of std::map --- Source/cmPropertyMap.cxx | 9 ++++++++- Source/cmPropertyMap.h | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 64bceb5..3ed4c05 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyMap.h" +#include #include void cmPropertyMap::Clear() @@ -59,15 +60,21 @@ std::vector cmPropertyMap::GetKeys() const for (auto const& item : Map_) { keyList.push_back(item.first); } + std::sort(keyList.begin(), keyList.end()); return keyList; } std::vector> cmPropertyMap::GetList() const { - std::vector> kvList; + typedef std::pair StringPair; + std::vector kvList; kvList.reserve(Map_.size()); for (auto const& item : Map_) { kvList.emplace_back(item.first, item.second); } + std::sort(kvList.begin(), kvList.end(), + [](StringPair const& a, StringPair const& b) { + return a.first < b.first; + }); return kvList; } diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 6284e8c..9aed349 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -5,11 +5,14 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include #include +#include #include #include +/** \class cmPropertyMap + * \brief String property map. + */ class cmPropertyMap { public: @@ -34,6 +37,7 @@ public: void RemoveProperty(const std::string& name); // -- Lists + //! Get a sorted list of property keys std::vector GetKeys() const; @@ -41,7 +45,7 @@ public: std::vector> GetList() const; private: - std::map Map_; + std::unordered_map Map_; }; #endif -- cgit v0.12