diff options
author | Brad King <brad.king@kitware.com> | 2015-11-13 18:05:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-06-19 15:08:26 (GMT) |
commit | afe3beb980a4780caecc12d3fc919feb3f9cce42 (patch) | |
tree | 4c5be698e3e8ec0dacb7fb4c2738fe79ffcae3cd /src/graph.cc | |
parent | 29a6e2fc6c671b9490193d4b235b53fb61886c80 (diff) | |
download | Ninja-afe3beb980a4780caecc12d3fc919feb3f9cce42.zip Ninja-afe3beb980a4780caecc12d3fc919feb3f9cce42.tar.gz Ninja-afe3beb980a4780caecc12d3fc919feb3f9cce42.tar.bz2 |
Refactor RecomputeDirty to take a node instead of an edge
All call sites have a node on which they call `in_edge()` to call
RecomputeDirty. Simplify call sites by taking the node directly and
calling `in_edge()` internally.
Diffstat (limited to 'src/graph.cc')
-rw-r--r-- | src/graph.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/graph.cc b/src/graph.cc index c90aaad..c34fab8 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -31,7 +31,16 @@ bool Node::Stat(DiskInterface* disk_interface, string* err) { return (mtime_ = disk_interface->Stat(path_, err)) != -1; } -bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { +bool DependencyScan::RecomputeDirty(Node* node, string* err) { + Edge* edge = node->in_edge(); + if (!edge) { + // This node has no in-edge; it is dirty if it is missing. + if (!node->exists()) + EXPLAIN("%s has no in-edge and is missing", node->path().c_str()); + node->set_dirty(!node->exists()); + return true; + } + bool dirty = false; edge->outputs_ready_ = true; edge->deps_missing_ = false; @@ -66,15 +75,8 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { if (!(*i)->status_known()) { if (!(*i)->StatIfNecessary(disk_interface_, err)) return false; - if (Edge* in_edge = (*i)->in_edge()) { - if (!RecomputeDirty(in_edge, err)) - return false; - } else { - // This input has no in-edge; it is dirty if it is missing. - if (!(*i)->exists()) - EXPLAIN("%s has no in-edge and is missing", (*i)->path().c_str()); - (*i)->set_dirty(!(*i)->exists()); - } + if (!RecomputeDirty(*i, err)) + return false; } // If an input is not ready, neither are our outputs. |