commit ffcbbeb996d95b3b402b62c0c43fdd54149c0bd9
Author: Haoxiang Fei <feihaoxiang@idea.edu.cn>
Date:
perf(casefold): look mappings up in a kind trie and match without folding
Every code point used to go through a binary search over all ~1,600 full
case folding (or ~10,700 NFKC_CF) mappings, ASCII included, and
caseless_match folded both strings in full before comparing them.
The generator now gives each code point a kind in a byte-valued trie:
identity, a mapping to cp + delta for the 254 most frequent deltas, or a
table lookup. Full case folding needs the search only for its 105
multi-code-point mappings. case_fold and nfkc_casefold share one loop that
handles ASCII without a lookup, copies unchanged runs at once and returns
unchanged input as a copy. caseless_match walks both strings code point by
code point and folds the rest only from the first longer mapping.
On native this is 3-21x faster (bench/casefoldperf, new), and the compiled
wasm-gc package is half the size.