Update `from_vb_unchecked` to use constant
What changed, and why it matters
This is a tiny code-quality change that replaces a hardcoded number (4) with a named constant already defined in the same file. It does not change behavior, fix a bug, or address any security issue.
No action needed; this is a non-security refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies Weight::from_vb_unchecked in units/src/weight.rs to multiply by Self::WITNESS_SCALE_FACTOR instead of the literal 4. The constant’s value is 4, so the compiled behavior is identical. It is a pure refactor with no functional or security impact.
Changed components
units/src/weight.rsInspect captured patch +1 / −1
diff --git a/units/src/weight.rs b/units/src/weight.rs
index e450978b..5c457f17 100644
--- a/units/src/weight.rs
+++ b/units/src/weight.rs
@@ -91,7 +91,7 @@ impl Weight {
}
/// Constructs a new [`Weight`] from virtual bytes without an overflow check.
- pub const fn from_vb_unchecked(vb: u64) -> Self { Weight::from_wu(vb * 4) }
+ pub const fn from_vb_unchecked(vb: u64) -> Self { Weight::from_wu(vb * Self::WITNESS_SCALE_FACTOR) }
/// Constructs a new [`Weight`] from witness size.
pub const fn from_witness_data_size(witness_size: u64) -> Self { Weight::from_wu(witness_size) }
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.