From 5fea2b44e4c2b19538ed99c10d24437cf28ae493 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Wed, 28 Jun 2023 22:56:41 +0200 Subject: [PATCH] Small performance improvement to avoid assignments if the list is empty. --- Recyclable.Collections/RecyclableList.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 1bd6214..5e86217 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -431,6 +431,11 @@ namespace Recyclable.Collections [MethodImpl(MethodImplOptions.NoInlining)] public void Clear() { + if (_count == 0) + { + return; + } + if (NeedsClearing) { Array.Clear(_memoryBlock, 0, _count);