Skip to main content

tac_bytes

Function tac_bytes 

Source
pub fn tac_bytes(
    data: &[u8],
    separator: u8,
    before: bool,
    out: &mut impl Write,
) -> Result<()>
Expand description

Reverse records separated by a single byte. Uses single forward SIMD pass to find separators, then builds reversed output.

For data up to CONTIG_LIMIT, builds a contiguous reversed output buffer and writes it in a single write_all(). This is much faster for pipe output than writev with many small slices (a 10MB file with 50-byte lines would need ~200 writev calls of 1024 entries each; a single 10MB write is faster).

For larger data, uses batched writev to avoid doubling memory usage.