Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions sdk/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u64>();
prefix.iter().all(|&x| x == 0)
&& aligned.iter().all(|&x| x == 0u64)
&& suffix.iter().all(|&x| x == 0u8)
}
bytes.iter().all(|b| *b == 0)
}