Forráskód Böngészése

Merge topic 'cmTarget_non_copyable'

204c5ccb43 cmMakefile: Use std::unordered_map::emplace to add cmTargets to the list

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3134
Brad King 6 éve
szülő
commit
4e47e9967a
2 módosított fájl, 11 hozzáadás és 10 törlés
  1. 10 8
      Source/cmGlobalGenerator.cxx
  2. 1 2
      Source/cmMakefile.cxx

+ 10 - 8
Source/cmGlobalGenerator.cxx

@@ -1214,14 +1214,16 @@ void cmGlobalGenerator::Configure()
   this->ConfigureDoneCMP0026AndCMP0024 = true;
 
   // Put a copy of each global target in every directory.
-  std::vector<GlobalTargetInfo> globalTargets;
-  this->CreateDefaultGlobalTargets(globalTargets);
-
-  for (cmMakefile* mf : this->Makefiles) {
-    cmTargets* targets = &(mf->GetTargets());
-    for (GlobalTargetInfo const& globalTarget : globalTargets) {
-      targets->insert(cmTargets::value_type(
-        globalTarget.Name, this->CreateGlobalTarget(globalTarget, mf)));
+  {
+    std::vector<GlobalTargetInfo> globalTargets;
+    this->CreateDefaultGlobalTargets(globalTargets);
+
+    for (cmMakefile* mf : this->Makefiles) {
+      auto& targets = mf->GetTargets();
+      for (GlobalTargetInfo const& globalTarget : globalTargets) {
+        targets.emplace(globalTarget.Name,
+                        this->CreateGlobalTarget(globalTarget, mf));
+      }
     }
   }
 

+ 1 - 2
Source/cmMakefile.cxx

@@ -2023,8 +2023,7 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type,
 {
   cmTargets::iterator it =
     this->Targets
-      .insert(cmTargets::value_type(
-        name, cmTarget(name, type, cmTarget::VisibilityNormal, this)))
+      .emplace(name, cmTarget(name, type, cmTarget::VisibilityNormal, this))
       .first;
   this->GetGlobalGenerator()->IndexTarget(&it->second);
   this->GetStateSnapshot().GetDirectory().AddNormalTargetName(name);