It appears that perfect hash is the one that works the best for my use case.
But if you put things into the perfect hash function it is not expecting, some fraction of them will collide.
If you're searching for a fixed set, look at the Ragel library. Compile-time generation of the search in a way that is very hard to beat.
marginalia_nu•3h ago
For sets that are plausibly sometimes going to be small where you're going to do a lot of membership checks, you can speculatively add a 64 bit bloom filter with a trivial hash function.
This sounds really stupid, but the cost of doing this is so small you can do it as a gamble. If it doesn't work out you've added like 10ns to your insertions and membership checks, but when it does work out, you can save an incredible amount of work.
Sesse__•3h ago
(I added some of these)
marginalia_nu•3h ago