summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2020-01-14 10:55:04 (GMT)
committerTim Blechmann <tim@klingt.org>2020-01-16 03:29:25 (GMT)
commit9d5a554cc9de0ac03d2da7dc95b8ef1db4a526e9 (patch)
treeaa91636887104b6c5a85023fde05373d107abfb1 /Source/cmGlobalGenerator.cxx
parent23e782ce05b5996536eff4c075d4bc36a8d8ba85 (diff)
downloadCMake-9d5a554cc9de0ac03d2da7dc95b8ef1db4a526e9.zip
CMake-9d5a554cc9de0ac03d2da7dc95b8ef1db4a526e9.tar.gz
CMake-9d5a554cc9de0ac03d2da7dc95b8ef1db4a526e9.tar.bz2
cmGlobalGenerator: Add cache for realpath() results
Cache the results of `realpath()` system calls in `cmGlobalGenerator` to avoid repeating such calls for the same paths over and over.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index bcc9050..c189ea5 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -7,6 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <functional>
#include <initializer_list>
#include <iterator>
#include <sstream>
@@ -3110,6 +3111,16 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const
return this->FilenameTargetDepends[sf];
}
+const std::string& cmGlobalGenerator::GetRealPath(const std::string& dir)
+{
+ auto i = this->RealPaths.lower_bound(dir);
+ if (i == this->RealPaths.end() ||
+ this->RealPaths.key_comp()(dir, i->first)) {
+ i = this->RealPaths.emplace_hint(i, dir, cmSystemTools::GetRealPath(dir));
+ }
+ return i->second;
+}
+
void cmGlobalGenerator::ProcessEvaluationFiles()
{
std::vector<std::string> generatedFiles;