From 0746f4b1ad15983244f832a3f46c752322dde00f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 18 Nov 2025 08:55:34 +0000 Subject: [PATCH] Eliminate clone of Pdu to queue during relations recursions. Signed-off-by: Jason Volk --- src/api/client/relations.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/client/relations.rs b/src/api/client/relations.rs index 5319bcbc..5ae11846 100644 --- a/src/api/client/relations.rs +++ b/src/api/client/relations.rs @@ -218,12 +218,12 @@ async fn get_relations( let mut stack: Vec<_> = pdus .iter() .filter(|_| max_depth > 0) - .map(|pdu| (pdu.clone(), 1)) + .map(|(count, _)| (*count, 1)) .collect(); - 'limit: while let Some(stack_pdu) = stack.pop() { - let target = match stack_pdu.0.0 { - | PduCount::Normal(c) => c, + 'limit: while let Some((count, depth)) = stack.pop() { + let target = match count { + | PduCount::Normal(count) => count, | PduCount::Backfilled(_) => { // TODO: Support backfilled relations 0 // This will result in an empty iterator @@ -236,13 +236,13 @@ async fn get_relations( .collect() .await; - for relation in relations { - if stack_pdu.1 < max_depth { - stack.push((relation.clone(), stack_pdu.1.saturating_add(1))); + for (count, pdu) in relations { + if depth < max_depth { + stack.push((count, depth.saturating_add(1))); } if pdus.len() < limit { - pdus.push(relation); + pdus.push((count, pdu)); } else { break 'limit; }