/// <summary> /// Clears the contents of this span. /// </summary> public unsafe void Clear() { int length = _length; if (length == 0) { return; } var byteLength = (UIntPtr)((uint)length * Unsafe.SizeOf <T>()); if ((Unsafe.SizeOf <T>() & (sizeof(IntPtr) - 1)) != 0) { if (_pinnable == null) { var ptr = (byte *)_byteOffset.ToPointer(); SpanHelpers.ClearLessThanPointerSized(ptr, byteLength); } else { ref byte b = ref Unsafe.As <T, byte>(ref Unsafe.AddByteOffset <T>(ref _pinnable.Data, _byteOffset)); SpanHelpers.ClearLessThanPointerSized(ref b, byteLength); } }