From 152f9a2f54a0c1f192e8f496eee62ea8f00033db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <> Date: Thu, 19 Feb 2026 22:02:28 -0500 Subject: [PATCH] dht: take shared_ptr by const-ref in sortedBucketInsert --- src/routing_table.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/routing_table.cpp b/src/routing_table.cpp index 6d1caae4..d7928e6e 100644 --- a/src/routing_table.cpp +++ b/src/routing_table.cpp @@ -97,19 +97,18 @@ std::vector> RoutingTable::findClosestNodes(const InfoHash id, time_point now, size_t count) const { std::vector> nodes; - nodes.reserve(count); auto bucket = findBucket(id); - if (bucket == end()) { return nodes; } + nodes.reserve(count); auto sortedBucketInsert = [&](const Bucket& b) { - for (auto n : b.nodes) { + for (const auto& n : b.nodes) { if (not n->isGood(now)) continue; - auto here = std::find_if(nodes.begin(), nodes.end(), [&id, &n](Sp& node) { + auto here = std::find_if(nodes.begin(), nodes.end(), [&id, &n](const Sp& node) { return id.xorCmp(n->id, node->id) < 0; }); nodes.insert(here, n); @@ -199,7 +198,7 @@ RoutingTable::onNewNode( if (confirm == 2) b->time = now; - for (auto& n : b->nodes) { + for (const auto& n : b->nodes) { if (n == node) return false; }