From: Matt Corallo Date: Tue, 7 Dec 2021 01:56:31 +0000 (+0000) Subject: Swap loop and condition order to avoid looping unnecessarily X-Git-Tag: v0.0.105~24^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=ee7cfa59d1ad569276115769eee18bf03f780a08;p=rust-lightning Swap loop and condition order to avoid looping unnecessarily --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index e20bfc87..f385bf25 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -4419,8 +4419,8 @@ impl Channel { txdata: &TransactionData, genesis_block_hash: BlockHash, node_pk: PublicKey, logger: &L) -> Result<(Option, Option), ClosureReason> where L::Target: Logger { let non_shutdown_state = self.channel_state & (!MULTI_STATE_FLAGS); - for &(index_in_block, tx) in txdata.iter() { - if let Some(funding_txo) = self.get_funding_txo() { + if let Some(funding_txo) = self.get_funding_txo() { + for &(index_in_block, tx) in txdata.iter() { // If we haven't yet sent a funding_locked, but are in FundingSent (ignoring // whether they've sent a funding_locked or not), check if we should send one. if non_shutdown_state & !(ChannelState::TheirFundingLocked as u32) == ChannelState::FundingSent as u32 {