Files
Velocity/proxy
Andrew Steinborn 1761755d4d Add perfect hashing for dense packet registries.
Since we know the set of packet mappings is always fixed, we can avoid dealing with hash collisions by coming up with a perfect hash function for each registry.

The algorithm used is very simple: we add an offset to the original object's hash code, mix the bits around (using fastutil HashCommon.mix()) and make sure the result is always positive before taking the remainder. The algorithm to generate the offset to the hash code (which we call a "key") is usually quick and is sped up by always rounding up to the next power of 2.

With this, we speed up writing out packet data by completely eliminating any need to check for hash collisions.
2021-08-20 03:59:34 -04:00
..