Tech News
← Home  ·  All topics

Perfect Hashing

1 GoKawiil brief on this topic

New open-source C++ library generates perfect hash functions for compile-time string lookups

A blog post describes a C++ technique for mapping fixed sets of strings (like HTTP methods or keywords) to values without runtime hash collisions. Following the design of the decades-old gperf tool, the approach builds an association table so each known key maps to a unique slot using only key length and a few selected characters. The author presents working code examples, including mapping HTTP methods such as GET, PUT, POST and DELETE to distinct slots via a simple formula.