summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsC.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-03-14 12:58:24 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-03-18 14:09:11 (GMT)
commit1de0c827a16e1ef5b4c6c900982c6a76061d2c97 (patch)
tree8da3fa0b174e26a14bbe1a97a9b3ddf2ec29c2d4 /Source/cmDependsC.cxx
parent5536cec46e9af9af3ee5756e59b57bcb7fa23e44 (diff)
downloadCMake-1de0c827a16e1ef5b4c6c900982c6a76061d2c97.zip
CMake-1de0c827a16e1ef5b4c6c900982c6a76061d2c97.tar.gz
CMake-1de0c827a16e1ef5b4c6c900982c6a76061d2c97.tar.bz2
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.
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r--Source/cmDependsC.cxx12
1 files 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 <utility>
#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;