private readonly ReadOnlySpan <byte> Slice(Span <byte> destination, uint offset, uint length) { ((uint)destination.Length).AssertGreaterEqual(length); uint end = offset + length; uint offsetRow = offset / Width; uint endRow = (end - 1U) / Width; var result = offsetRow == endRow? SliceFast(offset, length, offsetRow) : SliceSlow(destination, offset, length, offsetRow, endRow); #if !SHIPPING var copySlice = Source.ToArray().AsSpan().Slice((int)offset, (int)length); copySlice.SequenceEqual(result).AssertTrue(); #endif return(result); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryDebugView2D{T}"/> class with the specified parameters. /// </summary> /// <param name="span">The input <see cref="ReadOnlySpan2D{T}"/> instance with the items to display.</param> public MemoryDebugView2D(ReadOnlySpan2D <T> span) { this.Items = span.ToArray(); }