/// Reverse-complement lookup table for 4-base chunks encoded as u8 (2 bits/base, MSB-first).
/// REVCOMP4[x] is the reverse complement of the 4 bases encoded in x.
pub(crate) static REVCOMP4: [u8; 256] = build_revcomp4();

pub(crate) const fn revcomp4(x: u8) -> u8 {
    let x = !x;                                        // complement all bases
    let x = (x >> 4) | (x << 4);                      // swap nibbles
    let x = ((x >> 2) & 0x33) | ((x & 0x33) << 2);   // swap 2-bit groups
    x
}

const fn build_revcomp4() -> [u8; 256] {
    let mut table = [0u8; 256];
    let mut i = 0usize;
    while i < 256 {
        table[i] = revcomp4(i as u8);
        i += 1;
    }
    table
}
