summaryrefslogtreecommitdiffstats
path: root/src/graph.cc
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-09-14 00:32:09 (GMT)
committerPeter Collingbourne <peter@pcc.me.uk>2011-09-14 00:56:14 (GMT)
commit58fbb3c587117d798b368eec48a7d03f042961bb (patch)
tree6cd3514a915ac9db5e94338974c42d9efe8e1fa0 /src/graph.cc
parent3fbb25b2cc66f236a39b728d20e5d44da23612ac (diff)
downloadNinja-58fbb3c587117d798b368eec48a7d03f042961bb.zip
Ninja-58fbb3c587117d798b368eec48a7d03f042961bb.tar.gz
Ninja-58fbb3c587117d798b368eec48a7d03f042961bb.tar.bz2
Allocate space in the inputs vector for the depfile implicit deps
This speeds up a no-op LLVM/Clang build by about 20ms.
Diffstat (limited to 'src/graph.cc')
-rw-r--r--src/graph.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/graph.cc b/src/graph.cc
index 5c37ac0..643d74f 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -166,23 +166,26 @@ bool Edge::LoadDepFile(State* state, DiskInterface* disk_interface,
return false;
}
+ inputs_.insert(inputs_.end() - order_only_deps_, makefile.ins_.size(), 0);
+ implicit_deps_ += makefile.ins_.size();
+ vector<Node*>::iterator implicit_dep =
+ inputs_.end() - order_only_deps_ - makefile.ins_.size();
+
// Add all its in-edges.
for (vector<StringPiece>::iterator i = makefile.ins_.begin();
- i != makefile.ins_.end(); ++i) {
+ i != makefile.ins_.end(); ++i, ++implicit_dep) {
string path(i->str_, i->len_);
CanonicalizePath(&path);
Node* node = state->GetNode(path);
- inputs_.insert(inputs_.end() - order_only_deps_, node);
+ *implicit_dep = node;
node->out_edges_.push_back(this);
- ++implicit_deps_;
// If we don't have a edge that generates this input already,
// create one; this makes us not abort if the input is missing,
// but instead will rebuild in that circumstance.
if (!node->in_edge_) {
Edge* phony_edge = state->AddEdge(&State::kPhonyRule);
- phony_edge->order_only_deps_ = 1;
node->in_edge_ = phony_edge;
phony_edge->outputs_.push_back(node);
}