From 00f9a28729e3c4c0c18efecb99d19dd647592bc4 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Fri, 28 Nov 2025 15:51:19 +0100 Subject: [PATCH] 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. --- Source/Engine/Core/Collections/HashSetBase.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Engine/Core/Collections/HashSetBase.h b/Source/Engine/Core/Collections/HashSetBase.h index 96adabf79..58f1702c2 100644 --- a/Source/Engine/Core/Collections/HashSetBase.h +++ b/Source/Engine/Core/Collections/HashSetBase.h @@ -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; }