From 9729ce1bbcbfe5a78e7ac905cde0b8e8b6ba5c93 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 2 Aug 2015 15:08:42 +0100 Subject: [PATCH] simplify and fix multimap/multiset emplace --- ostd/internal/hashtable.hh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/ostd/internal/hashtable.hh b/ostd/internal/hashtable.hh index f0ed8b1..5f38a15 100644 --- a/ostd/internal/hashtable.hh +++ b/ostd/internal/hashtable.hh @@ -520,20 +520,10 @@ public: * gotta make sure that equal keys always come after * each other (this is then used by other APIs) */ - Size h = 0; - Chain *found = find(B::get_key(elem), h); - if (!found) { - Chain *ch = insert(h); - B::swap_elem(ch->value, elem); - return make_pair(Range(ch), true); - } - Chain *ch = request_node(); + Size h = bucket(B::get_key(elem)); + Chain *ch = insert(h); B::swap_elem(ch->value, elem); - Chain *next = found->next; - found->next = ch; - ch->prev = found; - ch->next = next; - if (next) next->prev = ch; + return make_pair(Range(ch), true); } Size h = bucket(B::get_key(elem)); Chain *found = nullptr;