using System; using System.Buffers; using System.Runtime.CompilerServices; namespace PerfectNumbers.Core; internal static class ThreadLocalArrayPool { [ThreadStatic] private static ArrayPool? s_threadPool; public static ArrayPool Shared { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ArrayPool? pool = s_threadPool; if (pool is null) { pool = ArrayPool.Create(); s_threadPool = pool; } return pool; } } }