Skip to content

Commit bdea7d9

Browse files
Initialize list_channels_with_filter result vec with capacity
1 parent 2e171a3 commit bdea7d9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,14 +1636,13 @@ where
16361636
}
16371637

16381638
fn list_channels_with_filter<Fn: FnMut(&(&[u8; 32], &Channel<<SP::Target as SignerProvider>::Signer>)) -> bool + Copy>(&self, f: Fn) -> Vec<ChannelDetails> {
1639-
let mut res = Vec::new();
16401639
// Allocate our best estimate of the number of channels we have in the `res`
16411640
// Vec. Sadly the `short_to_chan_info` map doesn't cover channels without
16421641
// a scid or a scid alias, and the `id_to_peer` shouldn't be used outside
16431642
// of the ChannelMonitor handling. Therefore reallocations may still occur, but is
16441643
// unlikely as the `short_to_chan_info` map often contains 2 entries for
16451644
// the same channel.
1646-
res.reserve(self.short_to_chan_info.read().unwrap().len());
1645+
let mut res = Vec::with_capacity(self.short_to_chan_info.read().unwrap().len());
16471646
{
16481647
let best_block_height = self.best_block.read().unwrap().height();
16491648
let per_peer_state = self.per_peer_state.read().unwrap();

0 commit comments

Comments
 (0)