From a42992f0b790caa11d658827e2009920c9facff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Wed, 15 Jan 2025 20:53:56 +0100 Subject: [PATCH] locator: clone `Arc`s only after filtering duplicates This is a tiny optimisation. --- scylla/src/routing/locator/replication_info.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scylla/src/routing/locator/replication_info.rs b/scylla/src/routing/locator/replication_info.rs index 16318dfd6d..7cae0ec558 100644 --- a/scylla/src/routing/locator/replication_info.rs +++ b/scylla/src/routing/locator/replication_info.rs @@ -64,8 +64,9 @@ impl ReplicationInfo { let unique_nodes_in_global_ring = global_ring .iter() - .map(|(_t, n)| n.clone()) + .map(|(_t, n)| n) .unique() + .cloned() .collect(); let mut datacenter_nodes: HashMap<&str, Vec<(Token, Arc)>> = HashMap::new(); @@ -82,7 +83,7 @@ impl ReplicationInfo { for (datacenter_name, this_datacenter_nodes) in datacenter_nodes { let dc_ring = TokenRing::new(this_datacenter_nodes.into_iter()); let unique_nodes_in_dc_ring = - dc_ring.iter().map(|(_t, n)| n.clone()).unique().collect(); + dc_ring.iter().map(|(_t, n)| n).unique().cloned().collect(); // When counting racks consider None as a separate rack let rack_count: usize = dc_ring .iter()