From 5f6c236481da552dfdbfff6579dc9d833993adad Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 27 Mar 2019 13:43:08 +0100 Subject: cmFiletimeCache: Add cmFiletimeCache::Remove method --- Source/cmFileTimeCache.cxx | 11 ++++++++--- Source/cmFileTimeCache.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/cmFileTimeCache.cxx b/Source/cmFileTimeCache.cxx index 1fff6a9..24d6bf6 100644 --- a/Source/cmFileTimeCache.cxx +++ b/Source/cmFileTimeCache.cxx @@ -14,8 +14,8 @@ bool cmFileTimeCache::Load(std::string const& fileName, cmFileTime& fileTime) { // Use the stored time if available. { - auto fit = this->FileTimes.find(fileName); - if (fit != this->FileTimes.end()) { + auto fit = this->Cache.find(fileName); + if (fit != this->Cache.end()) { fileTime = fit->second; return true; } @@ -25,10 +25,15 @@ bool cmFileTimeCache::Load(std::string const& fileName, cmFileTime& fileTime) return false; } // Store file time in cache - this->FileTimes[fileName] = fileTime; + this->Cache[fileName] = fileTime; return true; } +bool cmFileTimeCache::Remove(std::string const& fileName) +{ + return (this->Cache.erase(fileName) != 0); +} + bool cmFileTimeCache::Compare(std::string const& f1, std::string const& f2, int* result) { diff --git a/Source/cmFileTimeCache.h b/Source/cmFileTimeCache.h index a47904c..4f1a3a2 100644 --- a/Source/cmFileTimeCache.h +++ b/Source/cmFileTimeCache.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmFileTime.h" +#include "cmFileTime.h" // IWYU pragma: keep #include #include @@ -28,6 +28,12 @@ public: bool Load(std::string const& fileName, cmFileTime& fileTime); /** + * @brief Removes a file time from the cache + * @return true if the file was found in the cache and removed + */ + bool Remove(std::string const& fileName); + + /** * @brief Compare file modification times. * @return true for successful comparison and false for error. * @@ -44,8 +50,7 @@ public: bool DifferS(std::string const& f1, std::string const& f2); private: - typedef std::unordered_map FileTimeMap; - FileTimeMap FileTimes; + std::unordered_map Cache; }; #endif -- cgit v0.12