summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-20 14:43:05 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-11-20 14:44:19 (GMT)
commitdc24013bfc9537dba7b8b79411899b6afb34da14 (patch)
tree9aac8a298b45ddedc7a9000ac2a8bdc19875942c /Source/cmMakefile.cxx
parent9100ea1d82538b300145d589ca4961ff2050ac4d (diff)
parent4a6348dbbd35c51fabf01d517357129ed9480c85 (diff)
downloadCMake-dc24013bfc9537dba7b8b79411899b6afb34da14.zip
CMake-dc24013bfc9537dba7b8b79411899b6afb34da14.tar.gz
CMake-dc24013bfc9537dba7b8b79411899b6afb34da14.tar.bz2
Merge topic 'perf-source-lookup'
4a6348db Performance: Improve efficiency of source file lookup in cmMakefile Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1421
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5a11a90..0855e79 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3121,9 +3121,16 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
{
cmSourceFileLocation sfl(this, sourceName);
- for (cmSourceFile* sf : this->SourceFiles) {
- if (sf->Matches(sfl)) {
- return sf;
+ auto name = this->GetCMakeInstance()->StripExtension(sfl.GetName());
+#if defined(_WIN32) || defined(__APPLE__)
+ name = cmSystemTools::LowerCase(name);
+#endif
+ auto sfsi = this->SourceFileSearchIndex.find(name);
+ if (sfsi != this->SourceFileSearchIndex.end()) {
+ for (auto sf : sfsi->second) {
+ if (sf->Matches(sfl)) {
+ return sf;
+ }
}
}
return nullptr;
@@ -3137,6 +3144,14 @@ cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
sf->SetProperty("GENERATED", "1");
}
this->SourceFiles.push_back(sf);
+
+ auto name =
+ this->GetCMakeInstance()->StripExtension(sf->GetLocation().GetName());
+#if defined(_WIN32) || defined(__APPLE__)
+ name = cmSystemTools::LowerCase(name);
+#endif
+ this->SourceFileSearchIndex[name].push_back(sf);
+
return sf;
}