Fixed the bug that UnsafeSlotMap return wrong generation after resize.
This commit is contained in:
@@ -260,7 +260,10 @@ public unsafe struct UnsafeBitSet : IDisposable, IEquatable<UnsafeBitSet>
|
|||||||
var length = RoundToPadding(uints);
|
var length = RoundToPadding(uints);
|
||||||
|
|
||||||
_bits.Resize(length, option);
|
_bits.Resize(length, option);
|
||||||
_bits.AsSpan()[oldSize..].Clear();
|
if (!option.HasFlag(AllocationOption.Clear))
|
||||||
|
{
|
||||||
|
_bits.AsSpan()[oldSize..].Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
|
|||||||
public void Resize(int newSize, AllocationOption option = AllocationOption.None)
|
public void Resize(int newSize, AllocationOption option = AllocationOption.None)
|
||||||
{
|
{
|
||||||
_data.Resize(newSize, option);
|
_data.Resize(newSize, option);
|
||||||
_generations.Resize(newSize, option);
|
_generations.Resize(newSize, option | AllocationOption.Clear);
|
||||||
_freeSlots.Resize(newSize, option);
|
_freeSlots.Resize(newSize, option);
|
||||||
_validBits.Resize(newSize, option);
|
_validBits.Resize(newSize, option);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<Authors>Misaki</Authors>
|
<Authors>Misaki</Authors>
|
||||||
<AssemblyVersion>1.3.1</AssemblyVersion>
|
<AssemblyVersion>1.3.2</AssemblyVersion>
|
||||||
<Version>$(AssemblyVersion)</Version>
|
<Version>$(AssemblyVersion)</Version>
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>
|
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ using Misaki.HighPerformance.Collections;
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections;
|
using Misaki.HighPerformance.LowLevel.Collections;
|
||||||
|
|
||||||
var csm = new ConcurrentSlotMap<int>();
|
var csm = new UnsafeSlotMap<int>();
|
||||||
Console.WriteLine(csm.Contains(0, 0));
|
Console.WriteLine(csm.Contains(0, 0));
|
||||||
Console.WriteLine(csm.Count == 0);
|
Console.WriteLine(csm.Count == 0);
|
||||||
Reference in New Issue
Block a user