[repacker] optimize index_for_offset.
diff --git a/src/graph/graph.hh b/src/graph/graph.hh
index 4a036af..ab95a71 100644
--- a/src/graph/graph.hh
+++ b/src/graph/graph.hh
@@ -521,8 +521,11 @@
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;