COMMON: Fix HashMap never reusing erased items storage

When erasing and inserting many items this caused the hashmap capacity
to grow more than it should which resulted in performances issues (and
possibly memory issues as well). The issue was reported on IRC today
with the wintermute engine.
This commit is contained in:
Thierry Crozat 2018-07-30 19:18:52 +01:00
parent cb6d3b575c
commit 53d0fe22d9

View file

@ -507,7 +507,7 @@ typename HashMap<Key, Val, HashFunc, EqualFunc>::size_type HashMap<Key, Val, Has
#ifdef DEBUG_HASH_COLLISIONS
_dummyHits++;
#endif
if (first_free != _mask + 1)
if (first_free == NONE_FOUND)
first_free = ctr;
} else if (_equal(_storage[ctr]->_key, key)) {
found = true;
@ -528,7 +528,7 @@ typename HashMap<Key, Val, HashFunc, EqualFunc>::size_type HashMap<Key, Val, Has
(const void *)this, _mask + 1, _size);
#endif
if (!found && first_free != _mask + 1)
if (!found && first_free != NONE_FOUND)
ctr = first_free;
if (!found) {