public SlicedMemoryOwner(IMemoryOwner <T> memoryOwner, int start, int length) { if (memoryOwner is null) { throw new ArgumentNullException(nameof(memoryOwner)); } if (memoryOwner is SlicedMemoryOwner <T> slicedMemoryOwner) { this = new SlicedMemoryOwner <T>(slicedMemoryOwner, start, length); return; } var memoryLenght = memoryOwner.Memory.Length; if (start < 0 || start > memoryLenght) { throw new ArgumentOutOfRangeException(nameof(start)); } if (length > memoryLenght - start) { throw new ArgumentOutOfRangeException(nameof(length)); } _memoryOwner = memoryOwner; _start = start; _length = length; }
public SlicedMemoryOwner(SlicedMemoryOwner <T> memoryOwner, int start) { var memoryLenght = memoryOwner.Memory.Length; if (start < 0 || start > memoryLenght) { throw new ArgumentOutOfRangeException(nameof(start)); } _memoryOwner = memoryOwner._memoryOwner; _start = start + memoryOwner._start; _length = memoryOwner._length; }