summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-09-02 19:27:46 (GMT)
committerEvan Martin <martine@danga.com>2012-09-02 19:27:46 (GMT)
commit3220e626da48bc0fd69bee5a3dfae3b55bd0b761 (patch)
treea40cf4ad8e33205d13590fd781f88108882925e6 /src
parentfd91e0dc26d18209f7625730bb0e653f8321fff9 (diff)
downloadNinja-3220e626da48bc0fd69bee5a3dfae3b55bd0b761.zip
Ninja-3220e626da48bc0fd69bee5a3dfae3b55bd0b761.tar.gz
Ninja-3220e626da48bc0fd69bee5a3dfae3b55bd0b761.tar.bz2
remove a redundant arg to RecomputeOutputDirty
Diffstat (limited to 'src')
-rw-r--r--src/build.cc11
-rw-r--r--src/graph.cc29
-rw-r--r--src/graph.h3
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<Node*>::iterator ni = begin; ni != end; ++ni)
- if ((*ni)->mtime() > most_recent_input)
- most_recent_input = (*ni)->mtime();
+ Node* most_recent_input = NULL;
+ for (vector<Node*>::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<Node*>::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<Node*>::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);