Skip to content
Snippets Groups Projects
Commit 4e3cf8b0 authored by Brad King's avatar Brad King
Browse files

cmOrderDirectories: Reduce repeat realpath() calls

Since commit v3.1.0-rc1~110^2 (Tolerate symlinks during RPATH ordering,
2014-09-09) we call realpath() for every directory ordering constraint
check.  On some platforms/filesystems this is slow, so memoize the
result of the call for each directory.
parent 6b185287
No related branches found
No related tags found
No related merge requests found
......@@ -641,6 +641,19 @@ void cmOrderDirectories::DiagnoseCycle()
bool cmOrderDirectories::IsSameDirectory(std::string const& l,
std::string const& r)
{
return (l == r ||
cmSystemTools::GetRealPath(l) == cmSystemTools::GetRealPath(r));
return this->GetRealPath(l) == this->GetRealPath(r);
}
std::string const& cmOrderDirectories::GetRealPath(std::string const& dir)
{
std::map<std::string, std::string>::iterator i =
this->RealPaths.lower_bound(dir);
if (i == this->RealPaths.end() ||
this->RealPaths.key_comp()(dir, i->first))
{
typedef std::map<std::string, std::string>::value_type value_type;
i = this->RealPaths.insert(
i, value_type(dir, cmSystemTools::GetRealPath(dir)));
}
return i->second;
}
......@@ -83,6 +83,9 @@ private:
// Compare directories after resolving symlinks.
bool IsSameDirectory(std::string const& l, std::string const& r);
std::string const& GetRealPath(std::string const& dir);
std::map<std::string, std::string> RealPaths;
friend class cmOrderDirectoriesConstraint;
friend class cmOrderDirectoriesConstraintLibrary;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment