Fixed the bug that UnsafeSlotMap return wrong generation after resize.

This commit is contained in:
2025-12-12 16:35:04 +09:00
parent c4ca3e1bc9
commit 5184363e7d
4 changed files with 7 additions and 4 deletions

View File

@@ -260,7 +260,10 @@ public unsafe struct UnsafeBitSet : IDisposable, IEquatable<UnsafeBitSet>
var length = RoundToPadding(uints);
_bits.Resize(length, option);
_bits.AsSpan()[oldSize..].Clear();
if (!option.HasFlag(AllocationOption.Clear))
{
_bits.AsSpan()[oldSize..].Clear();
}
}
/// <summary>

View File

@@ -288,7 +288,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
public void Resize(int newSize, AllocationOption option = AllocationOption.None)
{
_data.Resize(newSize, option);
_generations.Resize(newSize, option);
_generations.Resize(newSize, option | AllocationOption.Clear);
_freeSlots.Resize(newSize, option);
_validBits.Resize(newSize, option);