From e17a69bc744ce0ed36e41be36694ca0053330d78 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 12 Mar 2014 01:48:06 -0400 Subject: 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. --- Source/cmDefinitions.cxx | 5 +++-- Source/cmDefinitions.h | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 6502163..5515f35 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -15,7 +15,8 @@ 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 { return i->second; } - else if(cmDefinitions* up = this->Up) + if(cmDefinitions* up = this->Up) { // Query the parent scope. return up->GetInternal(key); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index ebe6fa5..5209a8b 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -13,6 +13,9 @@ #define cmDefinitions_h #include "cmStandardIncludes.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include "cmsys/hash_map.hxx" +#endif /** \class cmDefinitions * \brief Store a scope of variable definitions for CMake language. @@ -71,7 +74,11 @@ private: cmDefinitions* Up; // Local definitions, set or unset. +#if defined(CMAKE_BUILD_WITH_CMAKE) + typedef cmsys::hash_map MapType; +#else typedef std::map MapType; +#endif MapType Map; // Internal query and update methods. -- cgit v0.12