Skip to main content

compress_bytes

Function compress_bytes 

Source
fn compress_bytes(value: u64, mask: u64) -> u64
Expand description

compress in constant time, a byte at a time and all bytes at once.

Within a byte each kept bit moves down by the number of dropped bits below it. Written in binary, that distance is at most 7, so three rounds move by 1, 2 and 4 the bits whose distance has that bit set (the parallel suffix network, Hacker’s Delight 7-4); shifts are masked to stay within the byte. Byte j then lands at the sum of the kept counts of bytes 0..j, all eight sums from one multiply by 0x0101..01.