From 276f2b319188ea905ebfc39ebaab684a2255c012 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Wed, 7 Dec 2011 08:33:49 -0800 Subject: refactor to remove Node::ready() --- src/build.cc | 6 ++---- src/graph.cc | 9 +++++++++ src/graph.h | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/build.cc b/src/build.cc index d074d2b..3da915d 100644 --- a/src/build.cc +++ b/src/build.cc @@ -220,8 +220,7 @@ bool Plan::AddSubTarget(Node* node, vector* stack, string* err) { if (node->dirty() && !want) { want = true; ++wanted_edges_; - if (find_if(edge->inputs_.begin(), edge->inputs_.end(), - not1(mem_fun(&Node::ready))) == edge->inputs_.end()) + if (edge->AllInputsReady()) ready_.insert(edge); if (!edge->is_phony()) ++command_edges_; @@ -295,8 +294,7 @@ void Plan::NodeFinished(Node* node) { continue; // See if the edge is now ready. - if (find_if((*i)->inputs_.begin(), (*i)->inputs_.end(), - not1(mem_fun(&Node::ready))) == (*i)->inputs_.end()) { + if ((*i)->AllInputsReady()) { if (want_i->second) { ready_.insert(*i); } else { diff --git a/src/graph.cc b/src/graph.cc index 424f941..818eb4f 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -143,6 +143,15 @@ bool Edge::RecomputeOutputDirty(BuildLog* build_log, time_t most_recent_input, return false; } +bool Edge::AllInputsReady() const { + for (vector::const_iterator i = inputs_.begin(); + i != inputs_.end(); ++i) { + if ((*i)->in_edge_ && !(*i)->in_edge_->outputs_ready()) + return false; + } + return true; +} + /// An Env for an Edge, providing $in and $out. struct EdgeEnv : public Env { EdgeEnv(Edge* edge) : edge_(edge) {} diff --git a/src/graph.h b/src/graph.h index 1a0b624..810d4ec 100644 --- a/src/graph.h +++ b/src/graph.h @@ -91,6 +91,9 @@ struct Edge { bool RecomputeOutputDirty(BuildLog* build_log, time_t most_recent_input, const string& command, Node* output); + /// Return true if all inputs' in-edges are ready. + bool AllInputsReady() const; + string EvaluateCommand(); // XXX move to env, take env ptr string EvaluateDepFile(); string GetDescription(); @@ -137,7 +140,6 @@ struct Node { Node(FileStat* file) : file_(file), dirty_(false), in_edge_(NULL) {} bool dirty() const { return dirty_; } - bool ready() const { return !in_edge_ || in_edge_->outputs_ready(); } FileStat* file_; bool dirty_; -- cgit v0.12