4 ms·
Switch tables tend to be computed goto based
by guipsp 4y ago
Switch tables tend to be computed goto based
- still_grokking 4y agoIs the interpreter we're talking about built this way?
- guipsp 4y agoEven if you write if...else a smart compiler will turn it into a switch table.
- still_grokking 4y agoCould you show an example? A Godbolt link would be nice!
- grose 4y agoHonestly I can't really say (I just ported it to WASM :-)), but here's more or less the start of the query loop: https://github.com/guregu/trealla/blob/main/src/query.c#L1733 https://github.com/guregu/trealla/blob/main/src/query.c#L173... I believe it's a bytecode but I know that function pointers are involved at least with the built-in predicates (see predicates.c).