summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-11-30 13:56:04 -0500
committerBrad King <brad.king@kitware.com>2019-04-18 08:21:44 -0400
commit325602ca41c76753470b991c7a47b76b15e4241b (patch)
tree3a0fe810e629519ca8ba32510c515827e08eb852
parentb08f3fb86909bf5b890e33936cf8fd44e1cbff47 (diff)
downloadninja-325602ca41c76753470b991c7a47b76b15e4241b.tar.gz
Explicitly avoid repeat deps loading
Track for each Edge whether depfile information has been loaded using an explicit flag. This will allow RecomputeDirty to be repeated for an edge without loading deps again.
-rw-r--r--src/graph.cc16
-rw-r--r--src/graph.h3
-rw-r--r--src/state.cc1
3 files changed, 13 insertions, 7 deletions
diff --git a/src/graph.cc b/src/graph.cc
index 9c2f784..bf9363d 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -75,12 +75,16 @@ bool DependencyScan::RecomputeDirty(Node* node, vector<Node*>* stack,
return false;
}
- if (!dep_loader_.LoadDeps(edge, err)) {
- if (!err->empty())
- return false;
- // Failed to load dependency info: rebuild to regenerate it.
- // LoadDeps() did EXPLAIN() already, no need to do it here.
- dirty = edge->deps_missing_ = true;
+ if (!edge->deps_loaded_) {
+ // This is our first encounter with this edge. Load discovered deps.
+ edge->deps_loaded_ = true;
+ if (!dep_loader_.LoadDeps(edge, err)) {
+ if (!err->empty())
+ return false;
+ // Failed to load dependency info: rebuild to regenerate it.
+ // LoadDeps() did EXPLAIN() already, no need to do it here.
+ dirty = edge->deps_missing_ = true;
+ }
}
// Visit all inputs; we're dirty if any of the inputs are dirty.
diff --git a/src/graph.h b/src/graph.h
index d58fecd..20af578 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -136,7 +136,7 @@ struct Edge {
};
Edge() : rule_(NULL), pool_(NULL), env_(NULL), mark_(VisitNone),
- outputs_ready_(false), deps_missing_(false),
+ outputs_ready_(false), deps_loaded_(false), deps_missing_(false),
implicit_deps_(0), order_only_deps_(0), implicit_outs_(0) {}
/// Return true if all inputs' in-edges are ready.
@@ -165,6 +165,7 @@ struct Edge {
BindingEnv* env_;
VisitMark mark_;
bool outputs_ready_;
+ bool deps_loaded_;
bool deps_missing_;
const Rule& rule() const { return *rule_; }
diff --git a/src/state.cc b/src/state.cc
index 9b3c7e1..74cf4c1 100644
--- a/src/state.cc
+++ b/src/state.cc
@@ -186,6 +186,7 @@ void State::Reset() {
i->second->ResetState();
for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) {
(*e)->outputs_ready_ = false;
+ (*e)->deps_loaded_ = false;
(*e)->mark_ = Edge::VisitNone;
}
}