summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-04-05 09:40:38 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-06 08:02:34 (GMT)
commitc5b26f3bec0e6e18255802da53886eae30a74021 (patch)
treee2aab9c6a9bd1923d09f96b991bf4f31de25d127 /Source/cmTarget.cxx
parenteb163f37d449af27fe8446c5d8d632aa295b6428 (diff)
downloadCMake-c5b26f3bec0e6e18255802da53886eae30a74021.zip
CMake-c5b26f3bec0e6e18255802da53886eae30a74021.tar.gz
CMake-c5b26f3bec0e6e18255802da53886eae30a74021.tar.bz2
cmTarget: Cache the cmSourceFiles in GetSourceFiles.
Avoid calling GetSourceFiles with the same result container multiple times when tracing target dependencies. The result from the previous configuration is cached and used later otherwise.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx39
1 files changed, 30 insertions, 9 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 22be57f..d28ac3f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -138,6 +138,10 @@ public:
LinkClosureMapType;
LinkClosureMapType LinkClosureMap;
+ typedef std::map<TargetConfigPair, std::vector<cmSourceFile*> >
+ SourceFilesMapType;
+ SourceFilesMapType SourceFilesMap;
+
struct TargetPropertyEntry {
TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
const std::string &targetName = std::string())
@@ -793,19 +797,33 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config,
cmTarget const* head) const
{
- std::vector<std::string> srcs;
- this->GetSourceFiles(srcs, config, head);
- std::set<cmSourceFile*> emitted;
+ // Lookup any existing link implementation for this configuration.
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
- for(std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i)
+ cmTargetInternals::SourceFilesMapType::iterator
+ it = this->Internal->SourceFilesMap.find(key);
+ if(it != this->Internal->SourceFilesMap.end())
+ {
+ files = it->second;
+ }
+ else
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
- if (emitted.insert(sf).second)
+ std::vector<std::string> srcs;
+ this->GetSourceFiles(srcs, config, head);
+
+ std::set<cmSourceFile*> emitted;
+
+ for(std::vector<std::string>::const_iterator i = srcs.begin();
+ i != srcs.end(); ++i)
{
- files.push_back(sf);
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ if (emitted.insert(sf).second)
+ {
+ files.push_back(sf);
+ }
}
+ this->Internal->SourceFilesMap[key] = files;
}
}
@@ -835,6 +853,7 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
}
if (!srcFiles.empty())
{
+ this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt);
@@ -969,6 +988,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src)
TargetPropertyEntryFinder(sfl))
== this->Internal->SourceEntries.end())
{
+ this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt);
@@ -1738,6 +1758,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
+ this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt);
@@ -1824,7 +1845,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
-
+ this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt);