Skip to content

Commit

Permalink
Microoptimization in LoadDepsFromLog().
Browse files Browse the repository at this point in the history
This cuts off another ~100 ms, most likely because the compiler
doesn't have smart enough alias analysis to do the same (trivial)
transformation.
  • Loading branch information
Steinar H. Gunderson committed Nov 5, 2024
1 parent ebca2de commit a0f10b9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,13 @@ bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, string* err) {
return false;
}

vector<Node*>::iterator implicit_dep =
PreallocateSpace(edge, deps->node_count);
for (int i = 0; i < deps->node_count; ++i, ++implicit_dep) {
Node* node = deps->nodes[i];
*implicit_dep = node;
node->AddOutEdge(edge);
Node** nodes = deps->nodes;
size_t node_count = deps->node_count;
edge->inputs_.insert(edge->inputs_.end() - edge->order_only_deps_,
nodes, nodes + node_count);
edge->implicit_deps_ += node_count;
for (size_t i = 0; i < node_count; ++i) {
nodes[i]->AddOutEdge(edge);
}
return true;
}
Expand Down

0 comments on commit a0f10b9

Please sign in to comment.