4 ms·
Indeed, a decent closed hash table is maybe 30 lines. An open hash table with linear probing is even less, especially if you don't need to remove entries. It's
by ludocode 1y ago
Indeed, a decent closed hash table is maybe 30 lines. An open hash table with linear probing is even less, especially if you don't need to remove entries. It's almost identical to a linear search through an array; you just change where you start iterating.
In my first stage Onramp linker [1], converting linear search to an open hash table adds a grand total of 24 bytecode instructions, including the FNV-1a hash function. There's no reason to ever linear search a symbol table.
[1]: https://github.com/ludocode/onramp/blob/develop/core/ld/0-global/ld.oe.ohx https://github.com/ludocode/onramp/blob/develop/core/ld/0-gl...
- bluGill 1y agoa linear search may be faster because it is cache and branch prediction frienly. Benchmarks on real world data is needed to make a final call.