Skip to content

Commit 2de3f2c

Browse files
committed
f Avoid superfluous collect
1 parent 735b89f commit 2de3f2c

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lightning/src/util/sweep.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,14 @@ where
318318
&self, mut output_descriptors: Vec<SpendableOutputDescriptor>,
319319
channel_id: Option<ChannelId>, exclude_static_ouputs: bool,
320320
) {
321-
let relevant_descriptors = if exclude_static_ouputs {
322-
output_descriptors
323-
.drain(..)
324-
.filter(|desc| !matches!(desc, SpendableOutputDescriptor::StaticOutput { .. }))
325-
.collect::<Vec<_>>()
326-
} else {
327-
output_descriptors
328-
};
329-
330-
if relevant_descriptors.is_empty() {
321+
let mut relevant_descriptors = output_descriptors
322+
.drain(..)
323+
.filter(|desc| {
324+
!(exclude_static_ouputs &&
325+
matches!(desc, SpendableOutputDescriptor::StaticOutput { .. }))
326+
}).peekable();
327+
328+
if relevant_descriptors.peek().is_none() {
331329
return;
332330
}
333331

0 commit comments

Comments
 (0)