▲ | dekhn 5 days ago | |||||||
A hash table in C is about 30 lines of code, so I don't think you have to stick to linked lists for dictionaries. | ||||||||
▲ | threeducks 4 days ago | parent | next [-] | |||||||
9 lines seem to be sufficient (assuming string keys and int values).
| ||||||||
▲ | ludocode 5 days ago | parent | prev | next [-] | |||||||
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-gl... | ||||||||
| ||||||||
▲ | bluGill 5 days ago | parent | prev [-] | |||||||
Sure but a linear search is 5. when my limit is 500 lines of C I don't dare spare those lines. |