From 2de3f2c4ffe4b066e7935771d17054fa85eb5f22 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Fri, 2 Feb 2024 09:55:20 +0100 Subject: [PATCH] f Avoid superfluous collect --- lightning/src/util/sweep.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lightning/src/util/sweep.rs b/lightning/src/util/sweep.rs index d144e96e202..5e726555fe4 100644 --- a/lightning/src/util/sweep.rs +++ b/lightning/src/util/sweep.rs @@ -318,16 +318,14 @@ where &self, mut output_descriptors: Vec, channel_id: Option, exclude_static_ouputs: bool, ) { - let relevant_descriptors = if exclude_static_ouputs { - output_descriptors - .drain(..) - .filter(|desc| !matches!(desc, SpendableOutputDescriptor::StaticOutput { .. })) - .collect::>() - } else { - output_descriptors - }; - - if relevant_descriptors.is_empty() { + let mut relevant_descriptors = output_descriptors + .drain(..) + .filter(|desc| { + !(exclude_static_ouputs && + matches!(desc, SpendableOutputDescriptor::StaticOutput { .. })) + }).peekable(); + + if relevant_descriptors.peek().is_none() { return; }