logoalt Hacker News

lelanthran • today at 12:28 PM • 0 replies • view on HN

> Why is the hashing needed and how is it faster than a regex? Can someone smarter than me explain?

It's a perfect hash (i.e. no collisions) that hash to an entry in a 32-element array.

Very similar to how we usually do quick lookups of strings for `switch()` statements: https://github.com/lelanthran/libxtree/blob/878cb4fc11ffd617...