From 1de0c827a16e1ef5b4c6c900982c6a76061d2c97 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 14 Mar 2019 13:58:24 +0100 Subject: cmDependsC: Read cache file modification time only once Using cmFileTime to store and compare file times in cmDependsC allows us to read the cache file modification time only once instead of over and over again for each comparison. --- Source/cmDependsC.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index a85f5ee..58b4ebb 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -6,6 +6,7 @@ #include #include "cmAlgorithms.h" +#include "cmFileTime.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -247,6 +248,8 @@ void cmDependsC::ReadCacheFile() cmIncludeLines* cacheEntry = nullptr; bool haveFileName = false; + cmFileTime cacheFileTime; + bool const cacheFileTimeGood = cacheFileTime.Load(this->CacheFileName); while (cmSystemTools::GetLineFromStream(fin, line)) { if (line.empty()) { cacheEntry = nullptr; @@ -256,11 +259,12 @@ void cmDependsC::ReadCacheFile() // the first line after an empty line is the name of the parsed file if (!haveFileName) { haveFileName = true; - int newer = 0; - bool res = - cmSystemTools::FileTimeCompare(this->CacheFileName, line, &newer); - if (res && newer == 1) // cache is newer than the parsed file + cmFileTime fileTime; + bool const res = cacheFileTimeGood && fileTime.Load(line); + bool const newer = res && cacheFileTime.Newer(fileTime); + + if (res && newer) // cache is newer than the parsed file { cacheEntry = new cmIncludeLines; this->FileCache[line] = cacheEntry; -- cgit v0.12