summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-06-19 14:45:08 (GMT)
committerBrad King <brad.king@kitware.com>2014-06-25 14:33:36 (GMT)
commit7b0834e9bbe614670552036b14c7556a3c76c9a9 (patch)
treecb9078bda20a3ddab8d56bd54083c67b6cb18d48
parentb8651d970d06325b9ad5166295e3bbc25052a8fd (diff)
downloadCMake-7b0834e9bbe614670552036b14c7556a3c76c9a9.zip
CMake-7b0834e9bbe614670552036b14c7556a3c76c9a9.tar.gz
CMake-7b0834e9bbe614670552036b14c7556a3c76c9a9.tar.bz2
cmTarget: Refactor internal LinkImplementation map
If ComputeLinkImplementationLanguages were ever to cause GetLinkImplementationLibraries to be invoked then a LinkImplMap entry may appear in the middle of computing it in GetLinkInformation. Instead create the map entry up front and store in it boolean values indicating which pieces of the LinkImplementation structure have been populated. This approach leads to shorter code that is easier to follow too.
-rw-r--r--Source/cmTarget.cxx55
1 files changed, 24 insertions, 31 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c8b1690..5bb15f5 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -144,8 +144,15 @@ public:
CompileInfoMapType CompileInfoMap;
// Cache link implementation computation from each configuration.
+ struct OptionalLinkImplementation: public cmTarget::LinkImplementation
+ {
+ OptionalLinkImplementation():
+ LibrariesDone(false), LanguagesDone(false) {}
+ bool LibrariesDone;
+ bool LanguagesDone;
+ };
typedef std::map<TargetConfigPair,
- cmTarget::LinkImplementation> LinkImplMapType;
+ OptionalLinkImplementation> LinkImplMapType;
LinkImplMapType LinkImplMap;
typedef std::map<std::string, cmTarget::LinkClosure> LinkClosureMapType;
@@ -6519,28 +6526,21 @@ cmTarget::GetLinkImplementation(const std::string& config) const
return 0;
}
- // Lookup any existing link implementation for this configuration.
+ // Populate the link implementation for this configuration.
TargetConfigPair key(this, cmSystemTools::UpperCase(config));
-
- cmTargetInternals::LinkImplMapType::iterator
- i = this->Internal->LinkImplMap.find(key);
- if(i == this->Internal->LinkImplMap.end())
+ cmTargetInternals::OptionalLinkImplementation&
+ impl = this->Internal->LinkImplMap[key];
+ if(!impl.LibrariesDone)
{
- // Compute the link implementation for this configuration.
- LinkImplementation impl;
+ impl.LibrariesDone = true;
this->ComputeLinkImplementation(config, impl, this);
- this->ComputeLinkImplementationLanguages(config, impl, this);
-
- // Store the information for this configuration.
- cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
- i = this->Internal->LinkImplMap.insert(entry).first;
}
- else if (i->second.Languages.empty())
+ if(!impl.LanguagesDone)
{
- this->ComputeLinkImplementationLanguages(config, i->second, this);
+ impl.LanguagesDone = true;
+ this->ComputeLinkImplementationLanguages(config, impl, this);
}
-
- return &i->second;
+ return &impl;
}
//----------------------------------------------------------------------------
@@ -6561,23 +6561,16 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config,
return 0;
}
- // Lookup any existing link implementation for this configuration.
+ // Populate the link implementation libraries for this configuration.
TargetConfigPair key(head, cmSystemTools::UpperCase(config));
-
- cmTargetInternals::LinkImplMapType::iterator
- i = this->Internal->LinkImplMap.find(key);
- if(i == this->Internal->LinkImplMap.end())
+ cmTargetInternals::OptionalLinkImplementation&
+ impl = this->Internal->LinkImplMap[key];
+ if(!impl.LibrariesDone)
{
- // Compute the link implementation for this configuration.
- LinkImplementation impl;
- this->ComputeLinkImplementation(config, impl, head);
-
- // Store the information for this configuration.
- cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
- i = this->Internal->LinkImplMap.insert(entry).first;
+ impl.LibrariesDone = true;
+ this->ComputeLinkImplementation(config, impl, this);
}
-
- return &i->second;
+ return &impl;
}
//----------------------------------------------------------------------------