From aadea3f682423ec539a7e7718b28e7d9e6d67ee6 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 1 Nov 2024 15:58:35 +0100 Subject: [PATCH] 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. --- src/graph.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/graph.cc b/src/graph.cc index f04ffb47c8..c1276daefb 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -740,12 +740,13 @@ bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, string* err) { return false; } - vector::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; }