MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / unpack_histogram

Function unpack_histogram

src/pack.rs:351–369  ·  view source on GitHub ↗
(
    packed_histogram: &[usize; FACTOR_POW_DIVISOR],
)

Source from the content-addressed store, hash-verified

349
350#[inline(never)]
351fn unpack_histogram<const FACTOR: usize, const FACTOR_POW_DIVISOR: usize>(
352 packed_histogram: &[usize; FACTOR_POW_DIVISOR],
353) -> [usize; FACTOR] {
354 let divisor = factor_to_divisor::<FACTOR>();
355 assert_eq!(FACTOR.pow(divisor as u32), FACTOR_POW_DIVISOR);
356 std::array::from_fn(|i| {
357 let mut sum = 0;
358 for level in 0..divisor {
359 let width = FACTOR.pow(level as u32);
360 let runs = FACTOR_POW_DIVISOR / (width * FACTOR);
361 for run in 0..runs {
362 let run_start = run * (width * FACTOR) + i * width;
363 let section = &packed_histogram[run_start..run_start + width];
364 sum += section.iter().copied().sum::<usize>();
365 }
366 }
367 sum
368 })
369}
370
371#[inline(always)]
372fn factor_to_divisor<const FACTOR: usize>() -> usize {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected