summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-12-07 16:33:49 (GMT)
committerEvan Martin <martine@danga.com>2011-12-07 16:33:49 (GMT)
commit276f2b319188ea905ebfc39ebaab684a2255c012 (patch)
tree7e7a52000ab001b19ff6c2e63fc4027d3759cc3a /src
parentb6b33fd295b2ed892f2d31a7d1b82dd21d7cf3bd (diff)
downloadNinja-276f2b319188ea905ebfc39ebaab684a2255c012.zip
Ninja-276f2b319188ea905ebfc39ebaab684a2255c012.tar.gz
Ninja-276f2b319188ea905ebfc39ebaab684a2255c012.tar.bz2
refactor to remove Node::ready()
Diffstat (limited to 'src')
-rw-r--r--src/build.cc6
-rw-r--r--src/graph.cc9
-rw-r--r--src/graph.h4
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<Node*>* 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<Node*>::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_;