diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h index efb7bafcf..d6af5f59d 100644 --- a/Source/Engine/Core/Collections/Dictionary.h +++ b/Source/Engine/Core/Collections/Dictionary.h @@ -403,7 +403,7 @@ public: ValueType& At(const KeyComparableType& key) { // Check if need to rehash elements (prevent many deleted elements that use too much of capacity) - if (_deletedCount > _size / DICTIONARY_DEFAULT_SLACK_SCALE) + if (_deletedCount * DICTIONARY_DEFAULT_SLACK_SCALE > _size) Compact(); // Ensure to have enough memory for the next item (in case of new element insertion) @@ -935,7 +935,7 @@ private: Bucket* OnAdd(const KeyComparableType& key) { // Check if need to rehash elements (prevent many deleted elements that use too much of capacity) - if (_deletedCount > _size / DICTIONARY_DEFAULT_SLACK_SCALE) + if (_deletedCount * DICTIONARY_DEFAULT_SLACK_SCALE > _size) Compact(); // Ensure to have enough memory for the next item (in case of new element insertion) diff --git a/Source/Engine/Core/Collections/HashSet.h b/Source/Engine/Core/Collections/HashSet.h index aa61354fd..f0e80c04f 100644 --- a/Source/Engine/Core/Collections/HashSet.h +++ b/Source/Engine/Core/Collections/HashSet.h @@ -730,7 +730,7 @@ private: Bucket* OnAdd(const ItemType& key) { // Check if need to rehash elements (prevent many deleted elements that use too much of capacity) - if (_deletedCount > _size / DICTIONARY_DEFAULT_SLACK_SCALE) + if (_deletedCount * DICTIONARY_DEFAULT_SLACK_SCALE > _size) Compact(); // Ensure to have enough memory for the next item (in case of new element insertion)