[Webkit-unassigned] [Bug 196681] HashTable::removeIf always shrinks the hash table by half even if there is nothing left

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Apr 6 20:48:25 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=196681

--- Comment #3 from Geoffrey Garen <ggaren at apple.com> ---
I don't think it's intentional. It's inconsistent with remove().

That said, it is true that shrinking to exactly your current size is usually a poor choice, since the very next insertion will grow.

One way to fix this is to do the shouldShrink test inside the loop.

Another way to fix this is to change the if (shouldShrink()) into a while (shouldShrink()).

Both of those are a bit wasteful, though.

The optimal solution is probably something like rehash(std::max(KeyTraits::minimumTableSize,  roundUpToPowerOfTwo(m_keyCount + 1)).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190407/872d3d72/attachment-0001.html>


More information about the webkit-unassigned mailing list