What changed, and why it matters
This commit adds compiler hints to three small functions in the rust-bitcoin hashes crate, suggesting the compiler should inline them. It does not change behavior, fix a bug, or address any security issue.
No security action needed. Treat as a routine optimization commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds #[inline] attributes to MaxLengthError::source() in hashes/src/hkdf/mod.rs and to MidstateError::midstate(), MidstateError::unprocessed_bytes(), and MidstateError::source() in hashes/src/sha256/mod.rs. These are pure performance/code-generation hints; the function bodies are unchanged.
Changed components
hashes/src/hkdf/mod.rshashes/src/sha256/mod.rsInspect captured patch +4 / −0
diff --git a/hashes/src/hkdf/mod.rs b/hashes/src/hkdf/mod.rs
index 351fed52..d7ac841f 100644
--- a/hashes/src/hkdf/mod.rs
+++ b/hashes/src/hkdf/mod.rs
@@ -166,6 +166,7 @@ pub mod error {
#[cfg(feature = "std")]
impl std::error::Error for MaxLengthError {
+ #[inline]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
}
}
diff --git a/hashes/src/sha256/mod.rs b/hashes/src/sha256/mod.rs
index e696fe66..744c5bc0 100644
--- a/hashes/src/sha256/mod.rs
+++ b/hashes/src/sha256/mod.rs
@@ -285,9 +285,11 @@ pub mod error {
impl MidstateError {
/// Returns block-aligned midstate.
+ #[inline]
pub const fn midstate(&self) -> &Midstate { &self.block_aligned_midstate }
/// returns the unprocessed bytes remaining in the buffer.
+ #[inline]
pub fn unprocessed_bytes(&self) -> &[u8] {
&self.unprocessed_bytes[..self.unprocessed_bytes_len]
}
@@ -309,6 +311,7 @@ pub mod error {
#[cfg(feature = "std")]
impl std::error::Error for MidstateError {
+ #[inline]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
}
}
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.