A Better UTF-8 Automaton
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
Orson Peters (orlp.net) presents a UTF-8 validation automaton built as a shift-DFA, where each byte indexes a table of 32-bit constants and the transition is a single shift. A SAT solver (Z3) packed the constants, halving the table to 1 KiB. An added SYNC state allows two overlapped chunks to be validated in parallel, and unmerged states make error recovery simple. The author's figures, which come from one benchmark on an Apple M5 and are unverified: about 2.5x slower than simdutf on Chinese text, and 9x faster than Höhrmann's validator.