瀏覽代碼

cmGlobalGenerator: Store targets in hash maps

Ben Boeckel 11 年之前
父節點
當前提交
325599caa2

+ 3 - 5
Source/cmGlobalGenerator.cxx

@@ -2070,15 +2070,13 @@ cmGlobalGenerator::FindTarget(const std::string& name,
 {
 {
   if (!excludeAliases)
   if (!excludeAliases)
     {
     {
-    std::map<std::string, cmTarget*>::const_iterator ai
-                                            = this->AliasTargets.find(name);
+    TargetMap::const_iterator ai = this->AliasTargets.find(name);
     if (ai != this->AliasTargets.end())
     if (ai != this->AliasTargets.end())
       {
       {
       return ai->second;
       return ai->second;
       }
       }
     }
     }
-  std::map<std::string,cmTarget *>::const_iterator i =
-    this->TotalTargets.find ( name );
+  TargetMap::const_iterator i = this->TotalTargets.find ( name );
   if ( i != this->TotalTargets.end() )
   if ( i != this->TotalTargets.end() )
     {
     {
     return i->second;
     return i->second;
@@ -2859,7 +2857,7 @@ void cmGlobalGenerator::WriteSummary()
   cmGeneratedFileStream fout(fname.c_str());
   cmGeneratedFileStream fout(fname.c_str());
 
 
   // Generate summary information files for each target.
   // Generate summary information files for each target.
-  for(std::map<std::string,cmTarget *>::const_iterator ti =
+  for(TargetMap::const_iterator ti =
         this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
         this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
     {
     {
     if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY)
     if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY)

+ 12 - 3
Source/cmGlobalGenerator.h

@@ -22,6 +22,10 @@
 #include "cmGeneratorTarget.h"
 #include "cmGeneratorTarget.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorExpression.h"
 
 
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+# include <cmsys/hash_map.hxx>
+#endif
+
 class cmake;
 class cmake;
 class cmGeneratorTarget;
 class cmGeneratorTarget;
 class cmGeneratorExpressionEvaluationFile;
 class cmGeneratorExpressionEvaluationFile;
@@ -389,9 +393,14 @@ protected:
   cmTargetManifest TargetManifest;
   cmTargetManifest TargetManifest;
 
 
   // All targets in the entire project.
   // All targets in the entire project.
-  std::map<std::string,cmTarget *> TotalTargets;
-  std::map<std::string,cmTarget *> AliasTargets;
-  std::map<std::string,cmTarget *> ImportedTargets;
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+#else
+  typedef std::map<std::string,cmTarget *> TargetMap;
+#endif
+  TargetMap TotalTargets;
+  TargetMap AliasTargets;
+  TargetMap ImportedTargets;
   std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
   std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
 
 
   virtual const char* GetPredefinedTargetsFolder();
   virtual const char* GetPredefinedTargetsFolder();

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.cxx

@@ -341,7 +341,7 @@ void cmGlobalVisualStudio8Generator::Generate()
   if(this->AddCheckTarget())
   if(this->AddCheckTarget())
     {
     {
     // All targets depend on the build-system check target.
     // All targets depend on the build-system check target.
-    for(std::map<std::string,cmTarget *>::const_iterator
+    for(TargetMap::const_iterator
           ti = this->TotalTargets.begin();
           ti = this->TotalTargets.begin();
         ti != this->TotalTargets.end(); ++ti)
         ti != this->TotalTargets.end(); ++ti)
       {
       {

+ 1 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -1219,7 +1219,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
 void cmGlobalXCodeGenerator::ForceLinkerLanguages()
 void cmGlobalXCodeGenerator::ForceLinkerLanguages()
 {
 {
   // This makes sure all targets link using the proper language.
   // This makes sure all targets link using the proper language.
-  for(std::map<std::string, cmTarget*>::const_iterator
+  for(TargetMap::const_iterator
         ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
         ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
     {
     {
     this->ForceLinkerLanguage(*ti->second);
     this->ForceLinkerLanguage(*ti->second);