summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-08 17:37:47 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-08 18:08:11 (GMT)
commit6cbf6a51976c9092f84ef4a90d35fb6fd60f5898 (patch)
tree3dfad2feee26d2e3d7100655029dbc4d2d27ab26 /Source/cmGlobalGenerator.h
parenta5a5a6857241c21d306661d723b749839f4c6e1a (diff)
downloadCMake-6cbf6a51976c9092f84ef4a90d35fb6fd60f5898.zip
CMake-6cbf6a51976c9092f84ef4a90d35fb6fd60f5898.tar.gz
CMake-6cbf6a51976c9092f84ef4a90d35fb6fd60f5898.tar.bz2
Fix internal target lookup performance regression
Refactoring in commit v3.5.0-rc1~272^2~13 (cmGlobalGenerator: Remove direct storage of targets, 2015-10-25) replaced an efficient data structure mapping from target name to cmTarget instance with a linear search. Lookups through cmGlobalGenerator::FindTarget are done a lot. Restore the efficient mapping structure with a name indicating its purpose. Reported-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'Source/cmGlobalGenerator.h')
-rw-r--r--Source/cmGlobalGenerator.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index bc6e17d..82bb35c 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -278,6 +278,8 @@ public:
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
bool needDisk = true);
+ void IndexTarget(cmTarget* t);
+
static bool IsReservedTarget(std::string const& name);
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
@@ -420,7 +422,6 @@ protected:
std::map<std::string, std::string> AliasTargets;
cmTarget* FindTargetImpl(std::string const& name) const;
- cmTarget* FindImportedTargetImpl(std::string const& name) const;
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
cmGeneratorTarget*
@@ -430,6 +431,21 @@ protected:
virtual bool UseFolderProperty();
private:
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string, cmTarget*> TargetMap;
+# else
+ typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+# endif
+#else
+ typedef std::map<std::string,cmTarget *> TargetMap;
+#endif
+ // Map efficiently from target name to cmTarget instance.
+ // Do not use this structure for looping over all targets.
+ // It contains both normal and globally visible imported targets.
+ TargetMap TargetSearchIndex;
+
cmMakefile* TryCompileOuterMakefile;
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator