summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorPierre Testart <ptestart@soundhound.com>2022-11-23 18:11:06 +0100
committerPierre Testart <ptestart@soundhound.com>2022-11-28 08:40:11 -0800
commitf69d1872dbddb81f73d9f1dac98def9ee153ea9f (patch)
treee2804e5a2e7658c28c2549a9e630316a9f82fa4f /Source/cmGeneratorTarget.cxx
parentb4e373aa9dd28f890e35a0dafc6a31994c8957c9 (diff)
downloadcmake-f69d1872dbddb81f73d9f1dac98def9ee153ea9f.tar.gz
cmGeneratorTarget: Add caches to some functions
Add caches to the following cmGeneratorTarget functions in order to improve performance: - GetIncludeDirectories - GetCompileOptions - GetCompileDefinitions - GetPrecompileHeaders - GetLinkOptions - GetLinkDirectories
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx58
1 files changed, 57 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index fae6d54e44..5ac4dd53c4 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -749,6 +749,12 @@ void cmGeneratorTarget::ClearSourcesCache()
this->VisitedConfigsForObjects.clear();
this->LinkImplMap.clear();
this->LinkImplUsageRequirementsOnlyMap.clear();
+ this->IncludeDirectoriesCache.clear();
+ this->CompileOptionsCache.clear();
+ this->CompileDefinitionsCache.clear();
+ this->PrecompileHeadersCache.clear();
+ this->LinkOptionsCache.clear();
+ this->LinkDirectoriesCache.clear();
}
void cmGeneratorTarget::ClearLinkInterfaceCache()
@@ -3829,6 +3835,13 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
const std::string& config, const std::string& lang) const
{
+ ConfigAndLanguage cacheKey(config, lang);
+ {
+ auto it = this->IncludeDirectoriesCache.find(cacheKey);
+ if (it != this->IncludeDirectoriesCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> includes;
std::unordered_set<std::string> uniqueIncludes;
@@ -3903,6 +3916,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
processIncludeDirectories(this, entries, includes, uniqueIncludes,
debugIncludes);
+ this->IncludeDirectoriesCache.emplace(cacheKey, includes);
return includes;
}
@@ -4080,6 +4094,13 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->CompileOptionsCache.find(cacheKey);
+ if (it != this->CompileOptionsCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
@@ -4106,6 +4127,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
processOptions(this, entries, result, uniqueOptions, debugOptions,
"compile options", OptionsParse::Shell);
+ CompileOptionsCache.emplace(cacheKey, result);
return result;
}
@@ -4167,6 +4189,13 @@ void cmGeneratorTarget::GetCompileDefinitions(
std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->CompileDefinitionsCache.find(cacheKey);
+ if (it != this->CompileDefinitionsCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> list;
std::unordered_set<std::string> uniqueOptions;
@@ -4220,12 +4249,20 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
processOptions(this, entries, list, uniqueOptions, debugDefines,
"compile definitions", OptionsParse::None);
+ this->CompileDefinitionsCache.emplace(cacheKey, list);
return list;
}
std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
const std::string& config, const std::string& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->PrecompileHeadersCache.find(cacheKey);
+ if (it != this->PrecompileHeadersCache.end()) {
+ return it->second;
+ }
+ }
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS",
@@ -4253,6 +4290,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
processOptions(this, entries, list, uniqueOptions, debugDefines,
"precompile headers", OptionsParse::None);
+ this->PrecompileHeadersCache.emplace(cacheKey, list);
return list;
}
@@ -4613,6 +4651,13 @@ void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result,
std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->LinkOptionsCache.find(cacheKey);
+ if (it != this->LinkOptionsCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
@@ -4690,7 +4735,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
// Last step: replace "LINKER:" prefixed elements by
// actual linker wrapper
- return this->ResolveLinkerWrapper(result, language);
+ result = this->ResolveLinkerWrapper(result, language);
+
+ this->LinkOptionsCache.emplace(cacheKey, result);
+ return result;
}
std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
@@ -4889,6 +4937,13 @@ void cmGeneratorTarget::GetLinkDirectories(std::vector<std::string>& result,
std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->LinkDirectoriesCache.find(cacheKey);
+ if (it != this->LinkDirectoriesCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueDirectories;
@@ -4918,6 +4973,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
processLinkDirectories(this, entries, result, uniqueDirectories,
debugDirectories);
+ this->LinkDirectoriesCache.emplace(cacheKey, result);
return result;
}