Skip to content

Commit 6c73829

Browse files
committed
f Avoid superfluous collect
1 parent 735b89f commit 6c73829

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lightning/src/util/sweep.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,18 @@ 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() {
331-
return;
332-
}
333-
321+
let relevant_descriptors = output_descriptors
322+
.drain(..)
323+
.filter(|desc| {
324+
!(exclude_static_ouputs &&
325+
matches!(desc, SpendableOutputDescriptor::StaticOutput { .. }))
326+
});
327+
328+
let mut processed_outputs = false;
334329
{
335330
let mut locked_outputs = self.outputs.lock().unwrap();
336331
for descriptor in relevant_descriptors {
332+
processed_outputs = true;
337333
let id = self.entropy_source.get_secure_random_bytes();
338334
let output_info = TrackedSpendableOutput {
339335
id,
@@ -353,7 +349,9 @@ where
353349
}
354350
}
355351

356-
self.rebroadcast_if_necessary();
352+
if processed_outputs {
353+
self.rebroadcast_if_necessary();
354+
}
357355
}
358356

359357
/// Returns a list of the currently tracked spendable outputs.

0 commit comments

Comments
 (0)