Skip to main content

is_all_zero

Function is_all_zero 

Source
pub fn is_all_zero(buf: &[u8]) -> bool
Expand description

Is every byte zero?

Public so benchmarks measure the implementation that actually ships; a private copy in a bench file is a benchmark of the bench file.

Two stages, and no unsafe. Real data almost always has a non-zero byte in its first cache line, so the prefix check rejects it after a single load. A genuine hole then runs the OR-fold, which has no per-word branch and so vectorises — unlike a short-circuiting all(), which does not.