diff --git a/Recyclable.Collections/RecyclableList.Helpers.cs b/Recyclable.Collections/RecyclableList.Helpers.cs index 47d324e..4064e99 100644 --- a/Recyclable.Collections/RecyclableList.Helpers.cs +++ b/Recyclable.Collections/RecyclableList.Helpers.cs @@ -237,7 +237,7 @@ namespace Recyclable.Collections : RecyclableArrayPool.Rent(list._capacity); // & WAS SLOWER WITHOUT - new Span(oldMemoryBlock).CopyTo(list._memoryBlock); + new Span(oldMemoryBlock, 0, list._count).CopyTo(list._memoryBlock); if (oldMemoryBlock.Length >= RecyclableDefaults.MinPooledArrayLength) { @@ -266,7 +266,7 @@ namespace Recyclable.Collections T[] oldMemoryBlock = sourceList._memoryBlock; // & WAS SLOWER AS ARRAY - new Span(oldMemoryBlock).CopyTo(newMemoryBlock); + new Span(oldMemoryBlock, 0, sourceList._count).CopyTo(newMemoryBlock); if (oldMemoryBlock.Length >= RecyclableDefaults.MinPooledArrayLength) { diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 00cd370..b6617fd 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -261,7 +261,7 @@ namespace Recyclable.Collections _ = RecyclableListHelpers.EnsureCapacity(this, targetCapacity); } - new Span(items._memoryBlock).CopyTo(new Span(_memoryBlock, _count, items._count)); + new Span(items._memoryBlock, 0, items._count).CopyTo(new Span(_memoryBlock, _count, items._count)); _count = targetCapacity; _version++; }