Hacker News new | past | comments | ask | show | jobs | submit login
String Matching Based on Compile Time Perfect Hashing in Zig (andrewkelley.me)
84 points by luu on Dec 4, 2018 | hide | past | favorite | 4 comments



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).


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


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


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)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: