diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-11-28 10:21:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-11-28 10:21:09 +0200 |
commit | 2908afbd6a9222b718c0f910edfbe2fc5943aad8 (patch) | |
tree | 91034caec661793da4c5368dd0a00431c3701d8a | |
parent | a50652b3e3323a9492c32d2ca6e97befd7d9755b (diff) |
Avoid unnecessary work in depdb::close() if using static check_mtime()
-rw-r--r-- | libbuild2/adhoc-rule-buildscript.cxx | 2 | ||||
-rw-r--r-- | libbuild2/cc/compile-rule.cxx | 2 | ||||
-rw-r--r-- | libbuild2/depdb.cxx | 4 | ||||
-rw-r--r-- | libbuild2/depdb.hxx | 6 |
4 files changed, 8 insertions, 6 deletions
diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index e8bc20d..b981b8d 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -505,7 +505,7 @@ namespace build2 if (update && dd.reading () && !ctx.dry_run) dd.touch = timestamp_unknown; - dd.close (); + dd.close (false /* mtime_check */); md->dd = move (dd.path); // Pass on base scope and update/mtime. diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index 3c77ad3..db9e6cb 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -1424,7 +1424,7 @@ namespace build2 if (u && dd.reading () && !ctx.dry_run) dd.touch = timestamp_unknown; - dd.close (); + dd.close (false /* mtime_check */); md.dd = move (dd.path); // If the preprocessed output is suitable for compilation, then pass diff --git a/libbuild2/depdb.cxx b/libbuild2/depdb.cxx index 1215e78..e50870c 100644 --- a/libbuild2/depdb.cxx +++ b/libbuild2/depdb.cxx @@ -281,7 +281,7 @@ namespace build2 } void depdb:: - close () + close (bool mc) { // If we are at eof, then it means all lines are good, there is the "end // marker" at the end, and we don't need to do anything, except, maybe @@ -329,7 +329,7 @@ namespace build2 change (true /* truncate */); } - if (mtime_check ()) + if (mc && mtime_check ()) start_ = system_clock::now (); if (state_ == state::write) diff --git a/libbuild2/depdb.hxx b/libbuild2/depdb.hxx index 9cff281..5b5052d 100644 --- a/libbuild2/depdb.hxx +++ b/libbuild2/depdb.hxx @@ -118,10 +118,12 @@ namespace build2 // function will "chop off" lines that haven't been read. // // Make sure to also call check_mtime() after updating the target to - // perform the target/database modification times sanity checks. + // perform the target/database modification times sanity checks. Pass + // false to close() to avoid unnecessary work if using the static version + // of check_mtime() (or not using it at all for some reason). // void - close (); + close (bool mtime_check = true); // Flush any unwritten data to disk. This is primarily useful when reusing // a (partially written) database as an input to external programs (e.g., |