Eliminate clone of Pdu to queue during relations recursions.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -218,12 +218,12 @@ async fn get_relations(
|
|||||||
let mut stack: Vec<_> = pdus
|
let mut stack: Vec<_> = pdus
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|_| max_depth > 0)
|
.filter(|_| max_depth > 0)
|
||||||
.map(|pdu| (pdu.clone(), 1))
|
.map(|(count, _)| (*count, 1))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
'limit: while let Some(stack_pdu) = stack.pop() {
|
'limit: while let Some((count, depth)) = stack.pop() {
|
||||||
let target = match stack_pdu.0.0 {
|
let target = match count {
|
||||||
| PduCount::Normal(c) => c,
|
| PduCount::Normal(count) => count,
|
||||||
| PduCount::Backfilled(_) => {
|
| PduCount::Backfilled(_) => {
|
||||||
// TODO: Support backfilled relations
|
// TODO: Support backfilled relations
|
||||||
0 // This will result in an empty iterator
|
0 // This will result in an empty iterator
|
||||||
@@ -236,13 +236,13 @@ async fn get_relations(
|
|||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
for relation in relations {
|
for (count, pdu) in relations {
|
||||||
if stack_pdu.1 < max_depth {
|
if depth < max_depth {
|
||||||
stack.push((relation.clone(), stack_pdu.1.saturating_add(1)));
|
stack.push((count, depth.saturating_add(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if pdus.len() < limit {
|
if pdus.len() < limit {
|
||||||
pdus.push(relation);
|
pdus.push((count, pdu));
|
||||||
} else {
|
} else {
|
||||||
break 'limit;
|
break 'limit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user