using System.Buffers; namespace SharpCompress; internal static class BufferPool { /// /// gets a buffer from the pool /// /// size of the buffer /// the buffer public static byte[] Rent(int bufferSize) { #if NETCOREAPP || NETSTANDARD2_1_OR_GREATER return ArrayPool.Shared.Rent(bufferSize); #else return new byte[bufferSize]; #endif } /// /// returns a buffer to the pool /// /// the buffer to return public static void Return(byte[] buffer) { #if NETCOREAPP || NETSTANDARD2_1_OR_GREATER ArrayPool.Shared.Return(buffer); #else // no-op #endif } }