public static OwnedMemory <T> Create(int size) { if (!Pool.TryTake(out OwnedPooledArray <T> ownedPooledArray)) { ownedPooledArray = new OwnedPooledArray <T>(); } ownedPooledArray._array = BufferPool <T> .Rent(size, false); ownedPooledArray._disposed = false; ownedPooledArray._referenceCount = 0; return(ownedPooledArray); }
public static OwnedBuffer <T> Create(T[] array) { if (Pool.TryTake(out OwnedPooledArray <T> pooled)) { var asOwnedPooledArray = pooled; // ReSharper disable once PossibleNullReferenceException asOwnedPooledArray.Initialize(array, 0, array.Length); return(asOwnedPooledArray); } return(new OwnedPooledArray <T>(array)); }
internal static TImpl Create(IMutableSeries <TKey, TValue> innerSeries) { TImpl inner; if (!Pool.TryTake(out inner)) { inner = new TImpl(); } inner.Inner = innerSeries; return(inner); }