Skip to content

Commit c97558a

Browse files
Steinar H. Gundersonsesse
Steinar H. Gunderson
authored andcommitted
Microoptimization in LoadDepsFromLog().
This cuts off another ~100 ms, most likely because the compiler doesn't have smart enough alias analysis to do the same (trivial) transformation.
1 parent cffec38 commit c97558a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/graph.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -740,12 +740,13 @@ bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, string* err) {
740740
return false;
741741
}
742742

743-
vector<Node*>::iterator implicit_dep =
744-
PreallocateSpace(edge, deps->node_count);
745-
for (int i = 0; i < deps->node_count; ++i, ++implicit_dep) {
746-
Node* node = deps->nodes[i];
747-
*implicit_dep = node;
748-
node->AddOutEdge(edge);
743+
Node** nodes = deps->nodes;
744+
size_t node_count = deps->node_count;
745+
edge->inputs_.insert(edge->inputs_.end() - edge->order_only_deps_,
746+
nodes, nodes + node_count);
747+
edge->implicit_deps_ += node_count;
748+
for (size_t i = 0; i < node_count; ++i) {
749+
nodes[i]->AddOutEdge(edge);
749750
}
750751
return true;
751752
}

0 commit comments

Comments
 (0)