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:
parent
cb6d3b575c
commit
53d0fe22d9
1 changed files with 2 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue