remove unnecessary clone in channel.rs
What changed, and why it matters
This is a tiny code cleanup that removes two unnecessary .clone() calls in a Lightning channel implementation. It does not change behavior, fix a bug, or address any security issue. It is purely a performance/maintainability micro-optimization.
No security action needed. Treat as a normal refactoring/cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes two variable usages in lightning/src/ln/channel.rs from passing cloned copies (payment_hash.clone(), onion_routing_packet.clone()) to moving the owned values directly. The surrounding code already owned these values, so the clones were redundant. The functional behavior is identical; only heap allocations and reference-count increments are avoided.
Changed components
lightning/src/ln/channel.rsInspect captured patch +2 / −2
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 9361cd3..478b7de 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -12525,9 +12525,9 @@ where
self.context.pending_outbound_htlcs.push(OutboundHTLCOutput {
htlc_id: self.context.next_holder_htlc_id,
amount_msat,
- payment_hash: payment_hash.clone(),
+ payment_hash,
cltv_expiry,
- state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
+ state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet)),
source,
blinding_point,
skimmed_fee_msat,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.