Eric Wong [off-list ref] writes:
khashl is an updated version of khash with less memory overhead
(one bit/bucket instead of two) than the original khash and
similar overall performance. Insertions are simpler (linear
probing) but deletions may be slightly slower[1]. Of course,
the majority of hash tables in git do not delete individual
elements.
$ make builtin/fast-import.sp ;# part of make sparse
SP builtin/fast-import.c
builtin/fast-import.c: note: in included file (through oidset.h, packfile.h):
khashl.h:516:1: error: Using plain integer as NULL pointer
khashl.h:516:1: error: Using plain integer as NULL pointer
make: *** [Makefile:3237: builtin/fast-import.sp] Error 1
I found IMPL_GET and IMPL_DEL's use of (h->keys == 0) were giving
one of these two, and managed to reduce the error to just one with
the attached patch, but I don't know what the other error is coming
from.
khashl.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git c/khashl.h w/khashl.h
index 8ffe80fbb2..663e36cd2d 100644
--- c/khashl.h
+++ w/khashl.h
@@ -101,7 +101,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
#define __KHASHL_IMPL_GET(SCOPE, HType, prefix, khkey_t, __hash_fn, __hash_eq) \
SCOPE khint_t prefix##_getp_core(const HType *h, const khkey_t *key, khint_t hash) { \
khint_t i, last, n_buckets, mask; \
- if (h->keys == 0) return 0; \
+ if (!h->keys) return 0; \
n_buckets = (khint_t)1U << h->bits; \
mask = n_buckets - 1U; \
i = last = __kh_h2b(hash, h->bits); \@@ -183,7 +183,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
#define __KHASHL_IMPL_DEL(SCOPE, HType, prefix, khkey_t, __hash_fn) \
SCOPE int prefix##_del(HType *h, khint_t i) { \
khint_t j = i, k, mask, n_buckets; \
- if (h->keys == 0) return 0; \
+ if (!h->keys) return 0; \
n_buckets = (khint_t)1U<<h->bits; \
mask = n_buckets - 1U; \
while (1) { \