mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 06:09:52 -06:00
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.
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <functional>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -3110,6 +3111,16 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const
|
|||||||
return this->FilenameTargetDepends[sf];
|
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()
|
void cmGlobalGenerator::ProcessEvaluationFiles()
|
||||||
{
|
{
|
||||||
std::vector<std::string> generatedFiles;
|
std::vector<std::string> generatedFiles;
|
||||||
|
|||||||
@@ -485,6 +485,8 @@ public:
|
|||||||
configs.emplace_back("$<CONFIG>");
|
configs.emplace_back("$<CONFIG>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const& GetRealPath(std::string const& dir);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// for a project collect all its targets by following depend
|
// for a project collect all its targets by following depend
|
||||||
// information, and also collect all the targets
|
// information, and also collect all the targets
|
||||||
@@ -676,6 +678,8 @@ private:
|
|||||||
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
|
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
|
||||||
FilenameTargetDepends;
|
FilenameTargetDepends;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> RealPaths;
|
||||||
|
|
||||||
#if !defined(CMAKE_BOOTSTRAP)
|
#if !defined(CMAKE_BOOTSTRAP)
|
||||||
// Pool of file locks
|
// Pool of file locks
|
||||||
cmFileLockPool FileLockPool;
|
cmFileLockPool FileLockPool;
|
||||||
|
|||||||
@@ -1177,7 +1177,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (std::string const& i : impDirVec) {
|
for (std::string const& i : impDirVec) {
|
||||||
if (implicitSet.insert(cmSystemTools::GetRealPath(i)).second) {
|
if (implicitSet.insert(this->GlobalGenerator->GetRealPath(i)).second) {
|
||||||
implicitDirs.emplace_back(i);
|
implicitDirs.emplace_back(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1188,7 +1188,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
|
|||||||
&lang](std::string const& dir) {
|
&lang](std::string const& dir) {
|
||||||
return (
|
return (
|
||||||
// Do not exclude directories that are not in an excluded set.
|
// Do not exclude directories that are not in an excluded set.
|
||||||
((!cmContains(implicitSet, cmSystemTools::GetRealPath(dir))) &&
|
((!cmContains(implicitSet, this->GlobalGenerator->GetRealPath(dir))) &&
|
||||||
(!cmContains(implicitExclude, dir)))
|
(!cmContains(implicitExclude, dir)))
|
||||||
// Do not exclude entries of the CPATH environment variable even though
|
// Do not exclude entries of the CPATH environment variable even though
|
||||||
// they are implicitly searched by the compiler. They are meant to be
|
// they are implicitly searched by the compiler. They are meant to be
|
||||||
|
|||||||
Reference in New Issue
Block a user