From 46b5dbd7ce05841d37b009c2d35004c147f44934 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 18 Aug 2022 01:18:16 +0000 Subject: [PATCH] [repacker] optimize index_for_offset. --- src/graph/graph.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 4a036af87..ab95a71c4 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -521,8 +521,11 @@ struct graph_t const auto& node = object (node_idx); if (offset < node.head || offset >= node.tail) return -1; - for (const auto& link : node.real_links) + unsigned length = node.real_links.length; + for (unsigned i = 0; i < length; i++) { + // Use direct access for increased performance, this is a hot method. + const auto& link = node.real_links.arrayZ[i]; if (offset != node.head + link.position) continue; return link.objidx;