From 5ee70abf934e026c9f945ad6461ca8486c671a24 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sat, 8 Jul 2023 14:28:36 +0200 Subject: [PATCH] Small performance improvement to benefit from .Net optimization for faster calls. --- Recyclable.Collections/RecyclableList.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index c50fe3f..180bd41 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -433,9 +433,8 @@ namespace Recyclable.Collections if (oldCount > 0) { - var sourceSpan = new Span(_memoryBlock, index, oldCount); - var targetSpan = new Span(_memoryBlock, index + 1, oldCount); - sourceSpan.CopyTo(targetSpan); + new Span(_memoryBlock, index, oldCount) + .CopyTo(new Span(_memoryBlock, index + 1, oldCount)); } _memoryBlock[index] = item;