Skip to main content

Module tr

Module tr 

Source

Functions§

complement
Parse a tr character set string into a Vec of expanded characters.
delete
delete_mmap
Delete from mmap’d byte slice.
delete_squeeze
delete_squeeze_mmap
Delete + squeeze from mmap’d byte slice.
expand_set2
Expand SET2 to match SET1 length for translation. If SET2 has [c*] repeats, fill them. Otherwise repeat last char.
parse_set
Parse a SET string into expanded bytes.
squeeze
squeeze_mmap
Squeeze from mmap’d byte slice.
translate
translate_mmap
Maximum data size for single-allocation translate approach. Translate bytes from an mmap’d byte slice. Detects single-range translations (e.g., a-z to A-Z) and uses SIMD vectorized arithmetic (AVX2: 32 bytes/iter, SSE2: 16 bytes/iter) for those cases. Falls back to scalar 256-byte table lookup for general translations.
translate_mmap_inplace
Translate bytes in-place on a mutable buffer (e.g., MAP_PRIVATE mmap). Eliminates the output buffer allocation entirely — the kernel’s COW semantics mean only modified pages are physically copied.
translate_mmap_readonly
Translate from a read-only mmap (or any byte slice) to a separate output buffer. Avoids MAP_PRIVATE COW page faults by reading from the original data and writing to a freshly allocated heap buffer.
translate_owned
Translate bytes in-place on an owned buffer, then write. For piped stdin where we own the data, this avoids the separate output buffer allocation needed by translate_mmap. Uses parallel in-place SIMD for large data.
translate_squeeze
translate_squeeze_mmap
Translate + squeeze from mmap’d byte slice.