Skip to content

Commit

Permalink
locator: clone Arcs only after filtering duplicates
Browse files Browse the repository at this point in the history
This is a tiny optimisation.
  • Loading branch information
wprzytula committed Jan 16, 2025
1 parent 369226c commit a42992f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scylla/src/routing/locator/replication_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Node>)>> = HashMap::new();
Expand All @@ -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()
Expand Down

0 comments on commit a42992f

Please sign in to comment.