Skip to content

Commit

Permalink
Fix of Dangerous SetChunk. Chunks should be rented (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhinZi committed Apr 16, 2024
1 parent 9533619 commit b434352
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Buffers;
using Arch.Core.Utils;

namespace Arch.Core.Extensions.Dangerous;
Expand Down Expand Up @@ -36,7 +37,9 @@ public static void SetSize(this Archetype archetype, int size)
/// <param name="chunks">The list of <see cref="Chunk"/>s.</param>
public static void SetChunks(this Archetype archetype, List<Chunk> chunks)
{
archetype.Chunks = chunks.ToArray();
archetype.Chunks = ArrayPool<Chunk>.Shared.Rent(chunks.Count);
chunks.CopyTo(archetype.Chunks);

archetype.ChunkCapacity = chunks.Count;
}

Expand Down

0 comments on commit b434352

Please sign in to comment.