Fixed HashSet compaction count after mid-compact growth
Ensure HashSetBase::Compact() preserves _elementsCount even when EnsureCapacity() triggers during compaction. The growth path resets the counter; we now cache the original count and restore it after moving all buckets so Count() stays correct in heavy-collision scenarios.
This commit is contained in:
@@ -408,6 +408,7 @@ protected:
|
||||
}
|
||||
else
|
||||
{
|
||||
const int32 elementsCount = _elementsCount;
|
||||
// Rebuild entire table completely
|
||||
const int32 oldSize = _size;
|
||||
AllocationData oldAllocation;
|
||||
@@ -437,6 +438,7 @@ protected:
|
||||
}
|
||||
for (int32 i = 0; i < oldSize; ++i)
|
||||
oldData[i].Free();
|
||||
_elementsCount = elementsCount;
|
||||
}
|
||||
_deletedCount = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user