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:
Michael Herzog
2025-11-28 15:51:19 +01:00
parent d9a18b1d31
commit 00f9a28729

View File

@@ -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;
}