Skip to content

Commit

Permalink
f Avoid superfluous collect
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Feb 2, 2024
1 parent 735b89f commit 2de3f2c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lightning/src/util/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,14 @@ where
&self, mut output_descriptors: Vec<SpendableOutputDescriptor>,
channel_id: Option<ChannelId>, exclude_static_ouputs: bool,
) {
let relevant_descriptors = if exclude_static_ouputs {
output_descriptors
.drain(..)
.filter(|desc| !matches!(desc, SpendableOutputDescriptor::StaticOutput { .. }))
.collect::<Vec<_>>()
} 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;
}

Expand Down

0 comments on commit 2de3f2c

Please sign in to comment.