From 57217c8f2a2dea07b41ecf05000172ce77a90466 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 4 Oct 2015 01:14:41 +0200 Subject: test: hashmap - cripple the hash function by truncating the input rather than the output The reason for the crippled hash function is to reduce the distribution of the hash function, do this by truncating the domain rather than the range. This does introduce a change in behavoir as the range is no longer contiguous, which greatly reduces collisions. This is needed as a follow-up patch will no longer allow individual hash functions to alter the output directly. --- src/test/test-hashmap-plain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index 057b6c1dc1..33ac93b395 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -693,7 +693,7 @@ static void test_hashmap_get2(void) { } static unsigned long crippled_hashmap_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) { - return trivial_hash_func(p, hash_key) & 0xff; + return trivial_hash_func(INT_TO_PTR(PTR_TO_INT(p) & 0xff), hash_key); } static const struct hash_ops crippled_hashmap_ops = { -- cgit v1.2.3-54-g00ecf