Re:Use perfect hashing, instead of binary search, for keywor...
by rurban on Friday January 11, 2019 @03:48AM
(#18881881)
I evaluated most of the available perfect hash generators a while ago, and gperf is not often the best. I've created much better ones.
But I haven't added this NetBSD code yet and also not yet the new perl5 mph code, will do soon.
The first step was to put only the needed keywords in a file, without the colons. I ran gperf with options to choose 3 specific character offsets and to use the length in the calculation; this was best after I tried a few choices. I then cleaned up the code and optimized it. I rounded the table size up to a power of 2, padding it correctly, and changed the length check to a mask. I switched the code over to using gcc's computed goto extension. I provided the keyword lengths, letting me use memcmp instead of strcmp. I inlined everything.