diff options
author | Brad King <brad.king@kitware.com> | 2014-07-10 20:59:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-14 13:51:51 (GMT) |
commit | c69e8a5580bd034dcaa1d7d53976200600b26b82 (patch) | |
tree | 609795a10f704373dbcd5e7f58d5cf1794755755 /Source | |
parent | 4db3990e9f3c11add85cba339b7a976f6f0fd3c5 (diff) | |
download | CMake-c69e8a5580bd034dcaa1d7d53976200600b26b82.zip CMake-c69e8a5580bd034dcaa1d7d53976200600b26b82.tar.gz CMake-c69e8a5580bd034dcaa1d7d53976200600b26b82.tar.bz2 |
cmTarget: Refactor internal LinkInterface map
Create the map entry up front and store in it boolean values indicating
which pieces of the LinkInterface structure have been populated.
This approach leads to shorter code that is easier to follow too.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmTarget.cxx | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1938d1..3361a81 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -112,9 +112,11 @@ public: struct OptionalLinkInterface: public cmTarget::LinkInterface { OptionalLinkInterface(): - Exists(false), Complete(false), ExplicitLibraries(0) {} + LibrariesDone(false), AllDone(false), + Exists(false), ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; bool Exists; - bool Complete; const char* ExplicitLibraries; }; void ComputeLinkInterface(cmTarget const* thisTarget, @@ -5895,32 +5897,26 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( // Lookup any existing link interface for this configuration. TargetConfigPair key(head, cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkInterfaceMapType::iterator - i = this->Internal->LinkInterfaceMap.find(key); - if(i == this->Internal->LinkInterfaceMap.end()) + cmTargetInternals::OptionalLinkInterface& + iface = this->Internal->LinkInterfaceMap[key]; + if(!iface.LibrariesDone) { - // Compute the link interface for this configuration. - cmTargetInternals::OptionalLinkInterface iface; + iface.LibrariesDone = true; iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, iface, head, false, iface.Exists); - if (iface.Exists) + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) { this->Internal->ComputeLinkInterface(this, config, iface, head, iface.ExplicitLibraries); } - - // Store the information for this configuration. - cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); - i = this->Internal->LinkInterfaceMap.insert(entry).first; - } - else if(!i->second.Complete && i->second.Exists) - { - this->Internal->ComputeLinkInterface(this, config, i->second, head, - i->second.ExplicitLibraries); } - return i->second.Exists ? &i->second : 0; + return iface.Exists? &iface : 0; } //---------------------------------------------------------------------------- @@ -5950,22 +5946,17 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, this->Internal->LinkInterfaceUsageRequirementsOnlyMap : this->Internal->LinkInterfaceMap); - cmTargetInternals::LinkInterfaceMapType::iterator i = lim.find(key); - if(i == lim.end()) + cmTargetInternals::OptionalLinkInterface& iface = lim[key]; + if(!iface.LibrariesDone) { - // Compute the link interface for this configuration. - cmTargetInternals::OptionalLinkInterface iface; + iface.LibrariesDone = true; iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, iface, head, usage_requirements_only, iface.Exists); - - // Store the information for this configuration. - cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); - i = lim.insert(entry).first; } - return i->second.Exists ? &i->second : 0; + return iface.Exists? &iface : 0; } //---------------------------------------------------------------------------- @@ -6348,7 +6339,6 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, sscanf(reps, "%u", &iface.Multiplicity); } } - iface.Complete = true; } //---------------------------------------------------------------------------- |