
String Matching Based on Compile Time Perfect Hashing in Zig - luu
https://andrewkelley.me/post/string-matching-comptime-perfect-hashing-zig.html
======
jononor
Very interesting. I've been thinking about writing a JSON parser for
microcontrollers that would work something like this. Typically in these cases
one only needs to support objects with a fixed set of keys, so such an
approach could take less progmem (no storing of string literals).

------
rurban
Nice and fast trick to find perfect hashes, but for more strings there should
be a fallback to the traditional methods: gperf (finding unique bytes) and an
indirect table lookup for hit and miss with offset

------
sytelus
This is very cool. So could this finally make efficient switch() statements
with string keys a reality?

~~~
xxs
java switch/case impl. is hash based but it includes equals as well. Perfect
hashing might work for short string but overall it won't be a major
improvement to contents check (one deference)

