Browse Source

cmPropertyMap: Rename GetPropertyList method to GetKeys

Sebastian Holtermann 6 years ago
parent
commit
9e64e617eb

+ 1 - 1
Source/cmCacheManager.cxx

@@ -620,7 +620,7 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const
 
 std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const
 {
-  return this->Properties.GetPropertyList();
+  return this->Properties.GetKeys();
 }
 
 const char* cmCacheManager::CacheEntry::GetProperty(

+ 1 - 7
Source/cmGeneratorTarget.cxx

@@ -5032,13 +5032,7 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
 
 std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
 {
-  cmPropertyMap const& propsObject = this->Target->GetProperties();
-  std::vector<std::string> props;
-  props.reserve(propsObject.size());
-  for (auto const& it : propsObject) {
-    props.push_back(it.first);
-  }
-  return props;
+  return this->Target->GetProperties().GetKeys();
 }
 
 void cmGeneratorTarget::ReportPropertyOrigin(

+ 10 - 11
Source/cmPropertyMap.cxx

@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmPropertyMap.h"
 
-#include <algorithm>
 #include <assert.h>
 #include <utility>
 
@@ -18,16 +17,6 @@ cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
   return prop;
 }
 
-std::vector<std::string> cmPropertyMap::GetPropertyList() const
-{
-  std::vector<std::string> keyList;
-  for (auto const& i : *this) {
-    keyList.push_back(i.first);
-  }
-  std::sort(keyList.begin(), keyList.end());
-  return keyList;
-}
-
 void cmPropertyMap::SetProperty(const std::string& name, const char* value)
 {
   if (!value) {
@@ -61,3 +50,13 @@ const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
   }
   return it->second.GetValue();
 }
+
+std::vector<std::string> cmPropertyMap::GetKeys() const
+{
+  std::vector<std::string> keyList;
+  keyList.reserve(this->size());
+  for (auto const& item : *this) {
+    keyList.push_back(item.first);
+  }
+  return keyList;
+}

+ 5 - 2
Source/cmPropertyMap.h

@@ -14,16 +14,19 @@
 class cmPropertyMap : public std::map<std::string, cmProperty>
 {
 public:
+  // -- Properties
   cmProperty* GetOrCreateProperty(const std::string& name);
 
-  std::vector<std::string> GetPropertyList() const;
-
   void SetProperty(const std::string& name, const char* value);
 
   void AppendProperty(const std::string& name, const char* value,
                       bool asString = false);
 
   const char* GetPropertyValue(const std::string& name) const;
+
+  // -- Lists
+  //! Get a sorted list of property keys
+  std::vector<std::string> GetKeys() const;
 };
 
 #endif

+ 1 - 7
Source/cmStateDirectory.cxx

@@ -6,7 +6,6 @@
 #include <algorithm>
 #include <assert.h>
 #include <iterator>
-#include <utility>
 
 #include "cmAlgorithms.h"
 #include "cmProperty.h"
@@ -667,12 +666,7 @@ bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const
 
 std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
 {
-  std::vector<std::string> keys;
-  keys.reserve(this->DirectoryState->Properties.size());
-  for (auto const& it : this->DirectoryState->Properties) {
-    keys.push_back(it.first);
-  }
-  return keys;
+  return this->DirectoryState->Properties.GetKeys();
 }
 
 void cmStateDirectory::AddNormalTargetName(std::string const& name)