using Newtonsoft.Json; using System.Buffers; namespace Shared.Engine.Utilities { public static class NewtonsoftPool { public static readonly IArrayPool Array = new NewtonsoftCharArrayPool(); } public class NewtonsoftCharArrayPool : IArrayPool { private readonly ArrayPool _pool; public NewtonsoftCharArrayPool(ArrayPool pool = null, bool clearOnReturn = false) { _pool = pool ?? ArrayPool.Shared; } public char[] Rent(int minimumLength) => _pool.Rent(PoolInvk.Rent(minimumLength)); public void Return(char[] array) => _pool.Return(array, clearArray: false); } }