From 3220e626da48bc0fd69bee5a3dfae3b55bd0b761 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Sun, 2 Sep 2012 12:27:46 -0700 Subject: remove a redundant arg to RecomputeOutputDirty --- src/build.cc | 11 ++++++----- src/graph.cc | 29 ++++++++++++----------------- src/graph.h | 3 +-- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/build.cc b/src/build.cc index 18bba9e..4102209 100644 --- a/src/build.cc +++ b/src/build.cc @@ -422,10 +422,11 @@ void Plan::CleanNode(DependencyScan* scan, Node* node) { end = (*ei)->inputs_.end() - (*ei)->order_only_deps_; if (find_if(begin, end, mem_fun(&Node::dirty)) == end) { // Recompute most_recent_input and command. - TimeStamp most_recent_input = 1; - for (vector::iterator ni = begin; ni != end; ++ni) - if ((*ni)->mtime() > most_recent_input) - most_recent_input = (*ni)->mtime(); + Node* most_recent_input = NULL; + for (vector::iterator ni = begin; ni != end; ++ni) { + if (!most_recent_input || (*ni)->mtime() > most_recent_input->mtime()) + most_recent_input = *ni; + } string command = (*ei)->EvaluateCommand(true); // Now, recompute the dirty state of each output. @@ -435,7 +436,7 @@ void Plan::CleanNode(DependencyScan* scan, Node* node) { if (!(*ni)->dirty()) continue; - if (scan->RecomputeOutputDirty(*ei, most_recent_input, NULL, + if (scan->RecomputeOutputDirty(*ei, most_recent_input, command, *ni)) { (*ni)->MarkDirty(); all_outputs_clean = false; diff --git a/src/graph.cc b/src/graph.cc index d73e38e..6ae324d 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -47,8 +47,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { } // Visit all inputs; we're dirty if any of the inputs are dirty. - TimeStamp most_recent_input = 1; - Node* most_recent_node = NULL; + Node* most_recent_input = NULL; for (vector::iterator i = edge->inputs_.begin(); i != edge->inputs_.end(); ++i) { if ((*i)->StatIfNecessary(disk_interface_)) { @@ -76,9 +75,8 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { EXPLAIN("%s is dirty", (*i)->path().c_str()); dirty = true; } else { - if ((*i)->mtime() > most_recent_input) { - most_recent_input = (*i)->mtime(); - most_recent_node = *i; + if (!most_recent_input || (*i)->mtime() > most_recent_input->mtime()) { + most_recent_input = *i; } } } @@ -92,8 +90,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { for (vector::iterator i = edge->outputs_.begin(); i != edge->outputs_.end(); ++i) { (*i)->StatIfNecessary(disk_interface_); - if (RecomputeOutputDirty(edge, most_recent_input, most_recent_node, - command, *i)) { + if (RecomputeOutputDirty(edge, most_recent_input, command, *i)) { dirty = true; break; } @@ -121,8 +118,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { } bool DependencyScan::RecomputeOutputDirty(Edge* edge, - TimeStamp most_recent_input, - Node* most_recent_node, + Node* most_recent_input, const string& command, Node* output) { if (edge->is_phony()) { @@ -140,25 +136,24 @@ bool DependencyScan::RecomputeOutputDirty(Edge* edge, } // Dirty if the output is older than the input. - if (output->mtime() < most_recent_input) { + if (most_recent_input && output->mtime() < most_recent_input->mtime()) { // If this is a restat rule, we may have cleaned the output with a restat // rule in a previous run and stored the most recent input mtime in the // build log. Use that mtime instead, so that the file will only be // considered dirty if an input was modified since the previous run. + TimeStamp most_recent_stamp = most_recent_input->mtime(); if (edge->rule_->restat() && build_log() && (entry = build_log()->LookupByOutput(output->path()))) { - if (entry->restat_mtime < most_recent_input) { + if (entry->restat_mtime < most_recent_stamp) { EXPLAIN("restat of output %s older than most recent input %s (%d vs %d)", - output->path().c_str(), - most_recent_node ? most_recent_node->path().c_str() : "", - entry->restat_mtime, most_recent_input); + output->path().c_str(), most_recent_input->path().c_str(), + entry->restat_mtime, most_recent_stamp); return true; } } else { EXPLAIN("output %s older than most recent input %s (%d vs %d)", - output->path().c_str(), - most_recent_node ? most_recent_node->path().c_str() : "", - output->mtime(), most_recent_input); + output->path().c_str(), most_recent_input->path().c_str(), + output->mtime(), most_recent_stamp); return true; } } diff --git a/src/graph.h b/src/graph.h index 3e2e57a..ced1f4f 100644 --- a/src/graph.h +++ b/src/graph.h @@ -212,8 +212,7 @@ struct DependencyScan { /// Recompute whether a given single output should be marked dirty. /// Returns true if so. - bool RecomputeOutputDirty(Edge* edge, TimeStamp most_recent_input, - Node* most_recent_node, + bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input, const string& command, Node* output); bool LoadDepFile(Edge* edge, string* err); -- cgit v0.12