summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaxim Kalaev <maximus.ka@gmail.com>2013-09-02 22:32:19 (GMT)
committerNico Weber <nicolasweber@gmx.de>2013-09-02 22:32:19 (GMT)
commit41c6258ec1928cbcfc5642504cb9c2b3659fa897 (patch)
tree5c13188a748ee68f36165e937d1e8675850af852 /src
parentd7a46654a7be1a46a777a8d8a51f065ac98ce05d (diff)
downloadNinja-41c6258ec1928cbcfc5642504cb9c2b3659fa897.zip
Ninja-41c6258ec1928cbcfc5642504cb9c2b3659fa897.tar.gz
Ninja-41c6258ec1928cbcfc5642504cb9c2b3659fa897.tar.bz2
Share more code between CleanNode() and RecomputeDirty().
Move a common loop into the new function RecomputeOutputsDirty(). Simplifies things a bit, and makes it harder for the restat path to have different behavior from the regular path. No dramatic behavior change (the restat path now also calls RestatIfNecessary()).
Diffstat (limited to 'src')
-rw-r--r--src/build.cc12
-rw-r--r--src/graph.cc26
-rw-r--r--src/graph.h10
3 files changed, 23 insertions, 25 deletions
diff --git a/src/build.cc b/src/build.cc
index 73dc1ff..76d317f 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -414,25 +414,17 @@ void Plan::CleanNode(DependencyScan* scan, Node* node) {
begin = (*ei)->inputs_.begin(),
end = (*ei)->inputs_.end() - (*ei)->order_only_deps_;
if (find_if(begin, end, mem_fun(&Node::dirty)) == end) {
- // Recompute most_recent_input and command.
+ // Recompute most_recent_input.
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, this edge is dirty if any of the outputs are dirty.
- bool dirty = false;
- for (vector<Node*>::iterator ni = (*ei)->outputs_.begin();
- !dirty && ni != (*ei)->outputs_.end(); ++ni) {
- dirty = scan->RecomputeOutputDirty(*ei, most_recent_input,
- command, *ni);
- }
-
// If the edge isn't dirty, clean the outputs and mark the edge as not
// wanted.
- if (!dirty) {
+ if (!scan->RecomputeOutputsDirty(*ei, most_recent_input)) {
for (vector<Node*>::iterator ni = (*ei)->outputs_.begin();
ni != (*ei)->outputs_.end(); ++ni) {
CleanNode(scan, *ni);
diff --git a/src/graph.cc b/src/graph.cc
index b58e17f..eeb3db1 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -106,18 +106,8 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) {
// We may also be dirty due to output state: missing outputs, out of
// date outputs, etc. Visit all outputs and determine whether they're dirty.
- if (!dirty) {
- string command = edge->EvaluateCommand(true);
-
- for (vector<Node*>::iterator i = edge->outputs_.begin();
- i != edge->outputs_.end(); ++i) {
- (*i)->StatIfNecessary(disk_interface_);
- if (RecomputeOutputDirty(edge, most_recent_input, command, *i)) {
- dirty = true;
- break;
- }
- }
- }
+ if (!dirty)
+ dirty = RecomputeOutputsDirty(edge, most_recent_input);
// Finally, visit each output to mark off that we've visited it, and update
// their dirty state if necessary.
@@ -139,6 +129,18 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) {
return true;
}
+bool DependencyScan::RecomputeOutputsDirty(Edge* edge,
+ Node* most_recent_input) {
+ string command = edge->EvaluateCommand(true);
+ for (vector<Node*>::iterator i = edge->outputs_.begin();
+ i != edge->outputs_.end(); ++i) {
+ (*i)->StatIfNecessary(disk_interface_);
+ if (RecomputeOutputDirty(edge, most_recent_input, command, *i))
+ return true;
+ }
+ return false;
+}
+
bool DependencyScan::RecomputeOutputDirty(Edge* edge,
Node* most_recent_input,
const string& command,
diff --git a/src/graph.h b/src/graph.h
index bd0cb34..d5d0f4f 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -240,10 +240,9 @@ struct DependencyScan {
/// Returns false on failure.
bool RecomputeDirty(Edge* edge, string* err);
- /// Recompute whether a given single output should be marked dirty.
+ /// Recompute whether any output of the edge is dirty.
/// Returns true if so.
- bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input,
- const string& command, Node* output);
+ bool RecomputeOutputsDirty(Edge* edge, Node* most_recent_input);
BuildLog* build_log() const {
return build_log_;
@@ -257,6 +256,11 @@ struct DependencyScan {
}
private:
+ /// Recompute whether a given single output should be marked dirty.
+ /// Returns true if so.
+ bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input,
+ const string& command, Node* output);
+
BuildLog* build_log_;
DiskInterface* disk_interface_;
ImplicitDepLoader dep_loader_;