From 0421e7b3c853100e3a2a0a3bc4ccd20cb891411b Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 20 Jul 2015 21:08:49 +0100 Subject: [PATCH] use calls to bucket() to get hashes --- ostd/internal/hashtable.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ostd/internal/hashtable.hh b/ostd/internal/hashtable.hh index abad3c4..69a303b 100644 --- a/ostd/internal/hashtable.hh +++ b/ostd/internal/hashtable.hh @@ -218,7 +218,7 @@ private: Chain *find(const K &key, Size &h) const { if (!p_size) return nullptr; - h = get_hash()(key) & (p_size - 1); + h = bucket(key); Chain **cp = p_data.first(); for (Chain *c = cp[h], *e = cp[h + 1]; c != e; c = c->next) if (get_eq()(key, B::get_key(c->value))) @@ -370,7 +370,7 @@ protected: memset(p_data.first(), 0, (p_size + 1) * sizeof(Chain *)); Chain **och = ht.p_data.first(); for (Chain *oc = *och; oc; oc = oc->next) { - Size h = get_hash()(B::get_key(oc->value)) & (p_size - 1); + Size h = bucket(B::get_key(oc->value)); Chain *nc = insert(h); allocator_destroy(get_alloc(), &nc->value); allocator_construct(get_alloc(), &nc->value, oc->value); @@ -409,7 +409,7 @@ protected: memset(p_data.first(), 0, (p_size + 1) * sizeof(Chain *)); Chain **och = ht.p_data.first(); for (Chain *oc = *och; oc; oc = oc->next) { - Size h = get_hash()(B::get_key(oc->value)) & (p_size - 1); + Size h = bucket(B::get_key(oc->value)); Chain *nc = insert(h); B::swap_elem(oc->value, nc->value); } @@ -512,7 +512,7 @@ public: Pair emplace(Args &&...args) { rehash_ahead(1); E elem(forward(args)...); - Size h = get_hash()(B::get_key(elem)) & (p_size - 1); + Size h = bucket(B::get_key(elem)); if (Multihash) { /* multihash: always insert */ Chain *ch = insert(h); @@ -539,7 +539,7 @@ public: Size erase(const K &key) { if (!p_len) return 0; Size olen = p_len; - Size h = get_hash()(key) & (p_size - 1); + Size h = bucket(key); Chain **cp = p_data.first(); for (Chain *c = cp[h], *e = cp[h + 1]; c != e; c = c->next) if (get_eq()(key, B::get_key(c->value))) { @@ -602,7 +602,7 @@ public: Chain *p = och ? *och : nullptr; while (p) { Chain *pp = p->next; - Size h = get_hash()(B::get_key(p->value)) & (p_size - 1); + Size h = bucket(B::get_key(p->value)); p->prev = p->next = nullptr; insert_node(h, p); p = pp;