diff options
author | Brad King <brad.king@kitware.com> | 2015-12-01 15:57:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-12-01 16:00:32 (GMT) |
commit | 4e3cf8b012404e4d9602c16d473480cc3d0c7928 (patch) | |
tree | 5621f044e6587bafdc03092e2967dcd70bd9dbe9 /Source/cmOrderDirectories.cxx | |
parent | 6b1852874325520a418eb05ec3c2149c2eb194a2 (diff) | |
download | CMake-4e3cf8b012404e4d9602c16d473480cc3d0c7928.zip CMake-4e3cf8b012404e4d9602c16d473480cc3d0c7928.tar.gz CMake-4e3cf8b012404e4d9602c16d473480cc3d0c7928.tar.bz2 |
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.
Diffstat (limited to 'Source/cmOrderDirectories.cxx')
-rw-r--r-- | Source/cmOrderDirectories.cxx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 9491204..e3406a8 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -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; } |