Optimize divide into multiply

This commit is contained in:
Wojtek Figat
2025-02-20 17:04:20 +01:00
parent 5bdf5da142
commit 3f2eab5206
2 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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)