4 ms·
> Both the utf8parse and vte crates that were written for Alacritty use table-driven parsers. The cool thing about these is that they have very little branching
by richdougherty 10y ago
> Both the utf8parse and vte crates that were written for Alacritty use table-driven parsers. The cool thing about these is that they have very little branching; utf8parse only has one branch in the entire library!
From a simplicity point of view table-driven parsing is pretty neat. However, it does mean you'll be getting a lot of branch misprediction in your single branch, since it's harder for the CPU to predict where it will branch to. You could probably go faster with some handcoding in the parser.
- ycmbntrthrwaway 10y agoRust has macros so any sort of tables can be rolled out into more efficient code, like if you wrote switch-case in C. It should be possible to rewrite vt_state_table! once later, when it becomes a problem.