deduplicate hashmap size doubling function

This commit is contained in:
dzaima 2022-09-07 19:27:14 +03:00
parent 1a583725be
commit 5d660cbf19
2 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#include "../core.h"
#define HASH_C 1
#include "hash.h"
#include "time.h"

View File

@ -106,7 +106,11 @@ static inline void N(qins) (Map* m, u64 h1, HT h2 IFKEY(, KT k) IFVAL(, VT v)) {
if (p++==mask) p = 0;
}
}
static NOINLINE void N(dbl) (Map** m) {
NOINLINE void N(dbl) (Map** m);
#if HASH_C
NOINLINE void N(dbl) (Map** m) {
Map* pm = *m;
u64 psz = pm->sz;
Map* nm = N(m)(psz*2);
@ -117,6 +121,7 @@ static NOINLINE void N(dbl) (Map** m) {
mm_free((Value*)pm);
*m = nm;
}
#endif
static inline u64 N(mk) (Map** mp, KT k, bool* had) {