]> git.kaiwu.me - klib.git/commitdiff
Remove bogus kh_del() in example code
authorDaniel Roethlisberger <daniel@roe.ch>
Sat, 11 Feb 2012 23:41:45 +0000 (00:41 +0100)
committerDaniel Roethlisberger <daniel@roe.ch>
Sat, 11 Feb 2012 23:41:45 +0000 (00:41 +0100)
The kh_del() causes the overwritten entry to be marked deleted and
subsequently not found when using kh_get().  For integer typed hash
tables, there is no need to check whether we are overwriting an existing
entry or creating a new one.

khash.h

diff --git a/khash.h b/khash.h
index a482fe1d878bce1f4c90750cf59988aaa60828f1..1a28e1184d75947b8d5ba84acedafd92772608c3 100644 (file)
--- a/khash.h
+++ b/khash.h
@@ -33,7 +33,6 @@ int main() {
        khiter_t k;
        khash_t(32) *h = kh_init(32);
        k = kh_put(32, h, 5, &ret);
-       if (!ret) kh_del(32, h, k);
        kh_value(h, k) = 10;
        k = kh_get(32, h, 10);
        is_missing = (k == kh_end(h));