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

Function check_less_than

src/pack.rs:219–228  ·  view source on GitHub ↗

Checks that `unpacked` bytes are less than `N`. All of `unpacked` is assumed to be < `FACTOR`. `HISTOGRAM` must be 0.

(
        unpacked: &[u8],
    )

Source from the content-addressed store, hash-verified

217 /// Checks that `unpacked` bytes are less than `N`. All of `unpacked` is assumed to be < `FACTOR`.
218 /// `HISTOGRAM` must be 0.
219 fn check_less_than<const N: usize, const HISTOGRAM: usize, const FACTOR: usize>(
220 unpacked: &[u8],
221 ) -> Result<[usize; HISTOGRAM]> {
222 assert!(FACTOR >= N);
223 debug_assert!(unpacked.iter().all(|&v| (v as usize) < FACTOR));
224 if FACTOR > N && unpacked.iter().copied().max().unwrap_or(0) as usize >= N {
225 return invalid_packing();
226 }
227 Ok(std::array::from_fn(|_| unreachable!("HISTOGRAM not 0")))
228 }
229
230 /// Returns `Ok(histogram)` if buckets after `OUT` are 0.
231 fn check_histogram<const IN: usize, const OUT: usize>(

Callers

nothing calls this directly

Calls 1

invalid_packingFunction · 0.85

Tested by

no test coverage detected