What’s exited has no branch in its body and no early exit
Compiled by KHAO Editorial — aggregated from 1 source. See llms.txt for citation guidance.
★ Tier-1 Source
A loop with no data-dependent control flow is trivially vectorizable: LLVM emits 16-byte-at-a-time NEON and the whole thing runs at > 45 GiB/s —memory bandwidth.
Key facts
- Measured, it’s ~2.6× slower —8.7 GiB/s versus the two-pass 23
- Slice the code space into 64-code-point “pages” and the ~1484 folds touch 59 of ~1960 possible pages
- This interval compression collapses the ~1484 individual folds into 238 runs across the 59 pages (≈four per…
- Because folding can make the string longer: almost every fold preserves the UTF-8 length or shrinks it, but two outliers grow— U+023A (Ⱥ) and U+023E (Ɀ) are 2 bytes each yet fold to 3-byte characters
Summary
Suppose a user searches for café and your corpus contains CAFÉ, or they type straße and you’ve stored STRASSE. It’s a basic operation, but at GitHub they run it a lot. This post is about how they made it fast, and it starts somewhere counterintuitive: the biggest win in the ASCII fast path came from removing an optimization, not adding one. It is tempting to reach for str::to_lowercase, but lowercasing and folding are different operations with different goals:. Lowercasing is for display, and it’s locale- and context-sensitive: Greek final sigma lowercases to ς at the end of a word and σ elsewhere, and Turkish the reporter lowercases differently than English the reporter.