4 ms·
I would have expected some hash tables instead of long chains of if-statements.
by silvestrov 4y ago
I would have expected some hash tables instead of long chains of if-statements.
- x3ro 4y agoWhy? If it’s not dynamic, why make your life harder and slower? Nothing beats a compare and jump compiled into your binary.
- yakubin 4y agoOnly as long as your compiler optimises it into a jump table, which is effectively a hash table.
- archi42 4y agoThe quirks are called at the appropriate places, and can be inlined using LTO. The same places would need to hash the current context and check if it's in the hash map (is it one global hash map, or a specialized one for each quirk, with an optimised hashing function?). And on a match, you need to do the full check anyway, due to likely collisions. The conditionals in the full check seem to use symbolised strings where possible, so they're quite fast. Probably faster than producing a suitable hash.
- deleted 4y ago[deleted]