Module byte_set
Expand description
const builders for [bool; 256] byte-set lookup tables.
A lookup table turns a byte-class predicate into a single branchless
load, which beats a match / compare-chain on hot per-byte paths (URI
validation, HTML tokenizing, …) and is deterministic across compilers.
Build the table once at const time, then index it by byte as usize.
Reach for a table only for irregular byte sets on a hot path: a simple
range such as b < 0x80 is one compare and should stay a comparison.
Constants§
- HTTP_
TCHAR - RFC 9110 §5.6.2
tchar, the byte class of HTTP tokens.
Functions§
- is_
http_ tchar - Whether
byteis an RFC 9110 §5.6.2tchar. - is_
http_ token - Whether
bytesis a non-empty RFC 9110 §5.6.2token(1*tchar). - set_
ascii_ alpha - Mark the ASCII alpha bytes (
A-Z,a-z) astrue. - set_
ascii_ alphanum - Mark the ASCII alphanumeric bytes (
0-9,A-Z,a-z) astrue. - set_
each - Mark every byte present in
bytesastrue. - set_
range - Mark every byte in the half-open range
[lo, hi_exclusive)astrue.