com.alicizax.unity.framework/Runtime/ObjectPool/SlotArrayPool.cs
陈思海 9afd5d9ff9 [Opt] ObjectPoolService && MemoryPool [Add]Benchmark Example
优化ObjcetPoolService 优化MemoryPoolService
增加ObjectPool 和MemoryPool的Benchmark
2026-04-27 14:38:24 +08:00

23 lines
532 B
C#

using System;
using System.Buffers;
namespace AlicizaX.ObjectPool
{
/// <summary>
/// 数组池管理器,避免频繁分配数组
/// </summary>
internal static class SlotArrayPool<T>
{
public static T[] Rent(int minimumLength)
{
return ArrayPool<T>.Shared.Rent(minimumLength);
}
public static void Return(T[] array, bool clearArray = false)
{
if (array != null)
ArrayPool<T>.Shared.Return(array, clearArray);
}
}
}