diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h index 544a70ca0..bdab15bbe 100644 --- a/Source/Engine/Core/Collections/Dictionary.h +++ b/Source/Engine/Core/Collections/Dictionary.h @@ -163,6 +163,15 @@ public: { } + /// + /// Initializes an empty without reserving any space. + /// + /// The custom allocation tag. + Dictionary(typename Base::AllocationTag tag) + : Base(tag) + { + } + /// /// Initializes by reserving space. /// diff --git a/Source/Engine/Core/Collections/HashSet.h b/Source/Engine/Core/Collections/HashSet.h index ab2601525..032a407db 100644 --- a/Source/Engine/Core/Collections/HashSet.h +++ b/Source/Engine/Core/Collections/HashSet.h @@ -140,6 +140,15 @@ public: { } + /// + /// Initializes an empty without reserving any space. + /// + /// The custom allocation tag. + HashSet(typename Base::AllocationTag tag) + : Base(tag) + { + } + /// /// Initializes by reserving space. /// diff --git a/Source/Engine/Core/Collections/HashSetBase.h b/Source/Engine/Core/Collections/HashSetBase.h index 200e26b7b..3b487227a 100644 --- a/Source/Engine/Core/Collections/HashSetBase.h +++ b/Source/Engine/Core/Collections/HashSetBase.h @@ -59,6 +59,7 @@ class HashSetBase public: // Type of allocation data used to store hash set buckets. using AllocationData = typename AllocationType::template Data; + using AllocationTag = typename AllocationType::Tag; protected: int32 _elementsCount = 0; @@ -70,6 +71,11 @@ protected: { } + HashSetBase(AllocationTag tag) + : _allocation(tag) + { + } + void MoveToEmpty(HashSetBase&& other) { _elementsCount = other._elementsCount; diff --git a/Source/Engine/Core/Memory/ArenaAllocation.h b/Source/Engine/Core/Memory/ArenaAllocation.h index af8df2001..7de7e0994 100644 --- a/Source/Engine/Core/Memory/ArenaAllocation.h +++ b/Source/Engine/Core/Memory/ArenaAllocation.h @@ -138,7 +138,7 @@ public: FORCE_INLINE void Swap(Data& other) { ::Swap(_data, other._data); - ::Swap(_arena, other._arena); + _arena = other._arena; // TODO: find a better way to move allocation with AllocationUtils::MoveToEmpty to preserve/maintain allocation tag ownership } }; };