summaryrefslogtreecommitdiffstats
path: root/Source/cmFileTimeComparison.cxx
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-10-21 21:52:51 (GMT)
committerBrad King <brad.king@kitware.com>2016-10-24 13:58:52 (GMT)
commit1a74e719068c97518d6f9521c86862a17166f32e (patch)
tree2f45312d552f2cc383871fff6ef1cd0cef847151 /Source/cmFileTimeComparison.cxx
parent1e555a44aa4e3d40bca2f88915c9f957098e5a55 (diff)
downloadCMake-1a74e719068c97518d6f9521c86862a17166f32e.zip
CMake-1a74e719068c97518d6f9521c86862a17166f32e.tar.gz
CMake-1a74e719068c97518d6f9521c86862a17166f32e.tar.bz2
Introduce CM_UNORDERED_MAP
Avoid duplicating switch among std::unordered_map, cmsys::hash_map, and std::map.
Diffstat (limited to 'Source/cmFileTimeComparison.cxx')
-rw-r--r--Source/cmFileTimeComparison.cxx34
1 files changed, 2 insertions, 32 deletions
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index a6c9cd0..55d8c2a 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -7,14 +7,7 @@
#include <time.h>
#include <utility>
-// Use a hash table to avoid duplicate file time checks from disk.
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include <cmsys/hash_map.hxx>
-#endif
-#endif
+#include "cm_unordered_map.hxx"
// Use a platform-specific API to get file times efficiently.
#if !defined(_WIN32) || defined(__CYGWIN__)
@@ -35,27 +28,9 @@ public:
bool FileTimesDiffer(const char* f1, const char* f2);
private:
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- // Use a hash table to efficiently map from file name to modification time.
- class HashString
- {
- public:
- size_t operator()(const std::string& s) const { return h(s.c_str()); }
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
- std::hash<const char*> h;
-#else
- cmsys::hash<const char*> h;
-#endif
- };
-#ifdef CMake_HAVE_CXX_UNORDERED_MAP
- typedef std::unordered_map<std::string,
-#else
- typedef cmsys::hash_map<std::string,
-#endif
- cmFileTimeComparison_Type, HashString>
+ typedef CM_UNORDERED_MAP<std::string, cmFileTimeComparison_Type>
FileStatsMap;
FileStatsMap Files;
-#endif
// Internal methods to lookup and compare modification times.
inline bool Stat(const char* fname, cmFileTimeComparison_Type* st);
@@ -68,7 +43,6 @@ private:
bool cmFileTimeComparisonInternal::Stat(const char* fname,
cmFileTimeComparison_Type* st)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
// Use the stored time if available.
cmFileTimeComparisonInternal::FileStatsMap::iterator fit =
this->Files.find(fname);
@@ -76,7 +50,6 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
*st = fit->second;
return true;
}
-#endif
#if !defined(_WIN32) || defined(__CYGWIN__)
// POSIX version. Use the stat function.
@@ -97,11 +70,8 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
*st = fdata.ftLastWriteTime;
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
// Store the time for future use.
this->Files[fname] = *st;
-#endif
-
return true;
}