util/set: optimize rehash for empty table and no-func clears
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 12 Jan 2021 17:20:41 +0000 (12:20 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 14 Jan 2021 13:51:35 +0000 (13:51 +0000)
commit5f3f128088ae45734723071ec4af340488ece741
treec9137032b31249f045a2b21b132acbe5b66efad3
parent41042f7fa29787347a4844a06a60b0c83fc916c1
util/set: optimize rehash for empty table and no-func clears

if the table is filled with deleted entries, we don't need to rzalloc+free an identical
block of memory for the table, we can just memset the existing one

the same applies to table clears without a function passed in that the table
doesn't need to be iterated and can just be memset

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8450>
src/util/set.c
src/util/tests/set/set_test.cpp