public T[] Rent(int minSize) { if (minSize < 0) { throw new ArgumentOutOfRangeException(nameof(minSize)); } if (minSize == 0) { return(Emptry); } var bucketIdx = BucketHelper.GetBucketIndex(minSize); if (bucketIdx < 0) { return(new T[minSize]); } var buff = _buckets[bucketIdx]; var returnBuff = buff.TryPop(); if (returnBuff != null) { return(returnBuff); } return(new T[minSize]); }
public void Return(T[] buff) { if (buff == null) { throw new ArgumentNullException(nameof(buff)); } if (buff.Length == 0) { return; } var bucketIndex = BucketHelper.GetBucketIndex(buff.Length); if (bucketIndex < 0) { return; } var buffer = _buckets[bucketIndex]; buffer.TryPush(buff); }