Re: [PATCH v4 02/14] add a hashtable implementation that supports O(1) removal
From: "Karsten Blees" <karsten.blees@gmail.com>
Show 8 quoted lines
> However, defining the constants inversely is a bit unintuitive (i.e.
> 1.25 instead of 0.8, 6 instead of 0.166). Perhaps the thresholds
> should also be calculated once on resize, not on every add / remove.
>
> What about this:
>
> #define HASHMAP_GROW_AT 80
> #define HASHMAP_SHRINK_AT 16
mico-bikeshed adding a code comment...
#define HASHMAP_GROW_AT 80 /* percent */
#define HASHMAP_SHRINK_AT 16 /* percent */
Show 8 quoted lines
>
> ...in rehash:
>
> map->grow_at = (unsigned int)((uint64_t) map->tablesize *
> HASHMAP_GROW_AT / 100);
> map->shrink_at = (unsigned int)((uint64_t) map->tablesize *
> HASHMAP_SHRINK_AT / 100);
>
[No need to add to cc...]
regards
Philip