From: Philip Oakley Date: Fri, 08 Nov 2013 14:13:30 GMT Subject: Re: [PATCH v4 02/14] add a hashtable implementation that supports O(1) removal Message-ID: <2BEA8A50DFB9411BA89CAB9236687F5B@PhilipOakley> In-Reply-To: <527CBC8E.6050507@gmail.com> From: "Karsten Blees" > 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 */ > > ...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