From: Alexey Tourbin Date: Wed, 15 Feb 2017 00:25:49 +0000 (+0300) Subject: Removed time_of_compilation check wrt SLOPPY_FILE_STAT_MATCHES X-Git-Tag: v3.3.5~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa16483c4792a030646b36ce3edd5c5dd935c919;p=thirdparty%2Fccache.git Removed time_of_compilation check wrt SLOPPY_FILE_STAT_MATCHES The whole code seems to be a thinko. For a hit, neither ctime nor mtime should be greater than or equal to time_of_compilation. The code only seems to work because time_of_compilation is 0 at this stage (i.e. has not been initialized). While at it, I also introduce an optimization: when sizes do not match, it's a good chance to bail out early; there is no point in further hashing the file. --- diff --git a/manifest.c b/manifest.c index 7c019e183..b84cc55a1 100644 --- a/manifest.c +++ b/manifest.c @@ -377,14 +377,12 @@ verify_object(struct conf *conf, struct manifest *mf, struct object *obj, hashtable_insert(stated_files, x_strdup(path), st); } + if (fi->size != st->size) { + return 0; + } + if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) { - // st->ctime is sometimes 0, so we can't check that both st->ctime and - // st->mtime are greater than time_of_compilation. But it's sufficient to - // check that either is. - if (fi->size == st->size - && fi->mtime == st->mtime - && fi->ctime == st->ctime - && MAX(st->mtime, st->ctime) >= time_of_compilation) { + if (fi->mtime == st->mtime && fi->ctime == st->ctime) { cc_log("size/mtime/ctime hit for %s", path); continue; } else {