diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-13 18:03:35 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-18 14:09:10 (GMT) |
commit | 31602583930b6c517c439ae8c15df26043031345 (patch) | |
tree | 78ee6064621ea8386cd0f7aef3b78977d0e01578 /Source | |
parent | 103aa9e46a5a59dc2c41cc1fa1aa6dd406b2924b (diff) | |
download | CMake-31602583930b6c517c439ae8c15df26043031345.zip CMake-31602583930b6c517c439ae8c15df26043031345.tar.gz CMake-31602583930b6c517c439ae8c15df26043031345.tar.bz2 |
cmFileTimeComparison: Replace anonymous private class with std::map
After the switch to `cmFileTime`, the anonymous private class of
`cmFileTimeComparison` held only a `std::map`. This moves the
`std::map` to the `cmFileTimeComparison` class itself and removes the
instantiation of an anonymous private class.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileTimeComparison.cxx | 61 | ||||
-rw-r--r-- | Source/cmFileTimeComparison.h | 8 |
2 files changed, 15 insertions, 54 deletions
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 5022cab..2115029 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -6,72 +6,33 @@ #include <unordered_map> #include <utility> -class cmFileTimeComparisonInternal -{ -public: - inline bool Load(std::string const& fname, cmFileTime& ftm); - inline bool FileTimeCompare(std::string const& f1, std::string const& f2, - int* result); - - bool FileTimesDiffer(std::string const& f1, std::string const& f2); +cmFileTimeComparison::cmFileTimeComparison() = default; -private: - typedef std::unordered_map<std::string, cmFileTime> FileStatsMap; - FileStatsMap Files; -}; +cmFileTimeComparison::~cmFileTimeComparison() = default; -bool cmFileTimeComparisonInternal::Load(std::string const& fname, - cmFileTime& ftm) +bool cmFileTimeComparison::Load(std::string const& fileName, + cmFileTime& fileTime) { // Use the stored time if available. { - auto fit = this->Files.find(fname); - if (fit != this->Files.end()) { - ftm = fit->second; + auto fit = this->FileTimes.find(fileName); + if (fit != this->FileTimes.end()) { + fileTime = fit->second; return true; } } // Read file time from OS - if (!ftm.Load(fname)) { + if (!fileTime.Load(fileName)) { return false; } // Store file time in cache - this->Files[fname] = ftm; + this->FileTimes[fileName] = fileTime; return true; } -cmFileTimeComparison::cmFileTimeComparison() -{ - this->Internals = new cmFileTimeComparisonInternal; -} - -cmFileTimeComparison::~cmFileTimeComparison() -{ - delete this->Internals; -} - -bool cmFileTimeComparison::Load(std::string const& fileName, - cmFileTime& fileTime) -{ - return this->Internals->Load(fileName, fileTime); -} - bool cmFileTimeComparison::FileTimeCompare(std::string const& f1, std::string const& f2, int* result) { - return this->Internals->FileTimeCompare(f1, f2, result); -} - -bool cmFileTimeComparison::FileTimesDiffer(std::string const& f1, - std::string const& f2) -{ - return this->Internals->FileTimesDiffer(f1, f2); -} - -bool cmFileTimeComparisonInternal::FileTimeCompare(std::string const& f1, - std::string const& f2, - int* result) -{ // Get the modification time for each file. cmFileTime ft1, ft2; if (this->Load(f1, ft1) && this->Load(f2, ft2)) { @@ -84,8 +45,8 @@ bool cmFileTimeComparisonInternal::FileTimeCompare(std::string const& f1, return false; } -bool cmFileTimeComparisonInternal::FileTimesDiffer(std::string const& f1, - std::string const& f2) +bool cmFileTimeComparison::FileTimesDiffer(std::string const& f1, + std::string const& f2) { // Get the modification time for each file. cmFileTime ft1, ft2; diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h index cc321f0..80ea409 100644 --- a/Source/cmFileTimeComparison.h +++ b/Source/cmFileTimeComparison.h @@ -7,8 +7,7 @@ #include "cmFileTime.h" #include <string> - -class cmFileTimeComparisonInternal; +#include <unordered_map> /** \class cmFileTimeComparison * \brief Caches file modification times in an internal map for fast lookups. @@ -45,8 +44,9 @@ public: */ bool FileTimesDiffer(std::string const& f1, std::string const& f2); -protected: - cmFileTimeComparisonInternal* Internals; +private: + typedef std::unordered_map<std::string, cmFileTime> FileTimeMap; + FileTimeMap FileTimes; }; #endif |