Skip to main content

count_all

Function count_all 

Source
pub fn count_all(data: &[u8], utf8: bool) -> WcCounts
Expand description

Count all metrics using optimized individual passes.

Each metric uses its own optimized algorithm:

  • Lines: SIMD-accelerated memchr
  • Words: 3-state scalar/state-machine (locale-dependent)
  • Chars: non-continuation byte counting (UTF-8) or byte counting (C locale)
  • Max line length: locale-aware display width tracking

Multi-pass is faster than single-pass because each pass has a tight, specialized loop. After the first pass, data is hot in L2/L3 cache, making subsequent passes nearly free for memory bandwidth.