Commit e17a69bc authored by Ben Boeckel's avatar Ben Boeckel Committed by Ben Boeckel
Browse files

cmDefinitions: Use a hashmap for faster checks

The hash map is much faster at checking that the map won't have what
we're looking for so that we can just go to the parent scope instead.
parent 3b21705d
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
cmDefinitions::Def cmDefinitions::NoDef; cmDefinitions::Def cmDefinitions::NoDef;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDefinitions::cmDefinitions(cmDefinitions* parent): Up(parent) cmDefinitions::cmDefinitions(cmDefinitions* parent)
: Up(parent)
{ {
} }
...@@ -35,7 +36,7 @@ cmDefinitions::GetInternal(const std::string& key) const ...@@ -35,7 +36,7 @@ cmDefinitions::GetInternal(const std::string& key) const
{ {
return i->second; return i->second;
} }
else if(cmDefinitions* up = this->Up) if(cmDefinitions* up = this->Up)
{ {
// Query the parent scope. // Query the parent scope.
return up->GetInternal(key); return up->GetInternal(key);
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#define cmDefinitions_h #define cmDefinitions_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmsys/hash_map.hxx"
#endif
/** \class cmDefinitions /** \class cmDefinitions
* \brief Store a scope of variable definitions for CMake language. * \brief Store a scope of variable definitions for CMake language.
...@@ -71,7 +74,11 @@ private: ...@@ -71,7 +74,11 @@ private:
cmDefinitions* Up; cmDefinitions* Up;
// Local definitions, set or unset. // Local definitions, set or unset.
#if defined(CMAKE_BUILD_WITH_CMAKE)
typedef cmsys::hash_map<std::string, Def> MapType;
#else
typedef std::map<std::string, Def> MapType; typedef std::map<std::string, Def> MapType;
#endif
MapType Map; MapType Map;
// Internal query and update methods. // Internal query and update methods.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment