mirror of
https://github.com/systemd/systemd.git
synced 2024-12-15 05:03:34 +08:00
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.
This commit is contained in:
parent
1283d70417
commit
57217c8f2a
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user