From 204c5ccb43e8a0bc937d8adac5eaa4b73f12140d Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 21 Mar 2019 20:06:00 +0100 Subject: cmMakefile: Use std::unordered_map::emplace to add cmTargets to the list When adding cmTargets to a cmMakefile, use std::unordered_map::emplace instead of std::unordered_map::insert. --- Source/cmGlobalGenerator.cxx | 18 ++++++++++-------- Source/cmMakefile.cxx | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6964b62..00781c3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/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 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 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)); + } } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ab37774..3832427 100644 --- a/Source/cmMakefile.cxx +++ b/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); -- cgit v0.12