From c43c5f36679acf051d6d1e177f370f3276af2f48 Mon Sep 17 00:00:00 2001 From: ivan770 Date: Wed, 19 Nov 2025 10:02:39 -0500 Subject: [PATCH] feat: Refactor is_zero implementation --- sdk/src/utils/mod.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/sdk/src/utils/mod.rs b/sdk/src/utils/mod.rs index eb96e3bb1..fdfe6340a 100644 --- a/sdk/src/utils/mod.rs +++ b/sdk/src/utils/mod.rs @@ -35,16 +35,8 @@ pub mod test; #[cfg(test)] pub(crate) mod test_signer; -// fast 0 vector test using byte alignment to perform faster native byte align comparison +/// Check if the provided byte slice is empty or contains all zeros. +#[inline] pub(crate) fn is_zero(bytes: &[u8]) -> bool { - if bytes.is_empty() { - return true; - } - - unsafe { - let (prefix, aligned, suffix) = bytes.align_to::(); - prefix.iter().all(|&x| x == 0) - && aligned.iter().all(|&x| x == 0u64) - && suffix.iter().all(|&x| x == 0u8) - } + bytes.iter().all(|b| *b == 0) }