aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorThierry Crozat2018-07-30 19:18:52 +0100
committerThierry Crozat2018-07-30 19:32:02 +0100
commit53d0fe22d902efa196ae1da03245d56f543c0ae2 (patch)
tree1d30e5c3d658c5b2e55ba7985551cb3c9f516ea2 /common
parentcb6d3b575c02782811fe01f213ca819984c87ab6 (diff)
downloadscummvm-rg350-53d0fe22d902efa196ae1da03245d56f543c0ae2.tar.gz
scummvm-rg350-53d0fe22d902efa196ae1da03245d56f543c0ae2.tar.bz2
scummvm-rg350-53d0fe22d902efa196ae1da03245d56f543c0ae2.zip
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.
Diffstat (limited to 'common')
-rw-r--r--common/hashmap.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/hashmap.h b/common/hashmap.h
index 1f93b68455..7913d8fc8b 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -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) {