remove redundant variable in compact_size encoding
What changed, and why it matters
This commit is a minor code cleanup in a Rust Bitcoin library. It removes an unnecessary intermediate variable when encoding very large numbers in a compact size format. There is no functional change and no security impact.
No security action needed. Treat as a normal code-quality refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff removes a redundant let v = value; binding in the _ => arm of compact_size::encode, replacing v.to_le_bytes() with value.to_le_bytes(). Since value implements ToU64 and the binding was only moved/used once, this is a pure refactor with identical compiled behavior. No logic, bounds, or encoding semantics changed.
Changed components
internals/src/compact_size.rsInspect captured patch +1 / −2
diff --git a/internals/src/compact_size.rs b/internals/src/compact_size.rs
index 37fc775c..7a047a08 100644
--- a/internals/src/compact_size.rs
+++ b/internals/src/compact_size.rs
@@ -69,9 +69,8 @@ pub fn encode(value: impl ToU64) -> ArrayVec<u8, MAX_ENCODING_SIZE> {
res.extend_from_slice(&v.to_le_bytes());
}
_ => {
- let v = value;
res.push(0xFF);
- res.extend_from_slice(&v.to_le_bytes());
+ res.extend_from_slice(&value.to_le_bytes());
}
}
res
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.