]> git.ipfire.org Git - thirdparty/haproxy.git/commit
DEV: phash: add a trivial perfect hash generator for integers
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Jan 2024 15:25:58 +0000 (16:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jan 2024 14:10:08 +0000 (15:10 +0100)
commit3e31e2927cdf309012e662ebe03b69a039b5c496
treee1ab7d4405d4fbe4e0a61991a40b19b20fcc64f5
parent3b0bf5097bb65e83c1ddb2f87c4eae43cc3000c8
DEV: phash: add a trivial perfect hash generator for integers

We have a few places where we're checking many status codes. The sets
are so small that just a multiply, a shift and an optional xor are
sufficient to turn that into a smaller set. The program used to produce
them is hackish as it allows to easily fiddle with various operations
manually and experiment by brute-forcing a pair of integers for the
mul and the xor. It also supports producing an incomplete table that
gives an easier modulo operation. Let's commit it as-is so that it can
be reused later (e.g. if new status codes are introduced for example).
dev/phash/phash.c [new file with mode: 0644]