From 9d5cefa518d9522fb27bc9b1a47ddddb22c884f5 Mon Sep 17 00:00:00 2001 From: sakno Date: Wed, 25 Oct 2023 20:52:41 +0300 Subject: [PATCH] Fixed Insertion test regression --- src/DotNext/Buffers/PooledArrayBufferWriter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DotNext/Buffers/PooledArrayBufferWriter.cs b/src/DotNext/Buffers/PooledArrayBufferWriter.cs index e0d5c3c2e..38699bf0a 100644 --- a/src/DotNext/Buffers/PooledArrayBufferWriter.cs +++ b/src/DotNext/Buffers/PooledArrayBufferWriter.cs @@ -507,7 +507,9 @@ private static void CopyFast(T[] source, T[] destination, int length) Debug.Assert(length <= source.Length); Debug.Assert(length <= destination.Length); - source.CopyTo(MemoryMarshal.CreateSpan(ref MemoryMarshal.GetArrayDataReference(destination), length)); + var src = MemoryMarshal.CreateReadOnlySpan(ref MemoryMarshal.GetArrayDataReference(source), length); + var dest = MemoryMarshal.CreateSpan(ref MemoryMarshal.GetArrayDataReference(destination), length); + src.CopyTo(dest); } [MethodImpl(MethodImplOptions.AggressiveInlining)]