From 97d5d9c6a38a2db948d5a388c1dae26df7c398f5 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Wed, 22 Mar 2023 01:22:01 +0100 Subject: [PATCH] RecyclableArrayList.Contains fixed to respect empty list. --- Recyclable.Collections/RecyclableArrayList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Recyclable.Collections/RecyclableArrayList.cs b/Recyclable.Collections/RecyclableArrayList.cs index 561ac61..ce4caee 100644 --- a/Recyclable.Collections/RecyclableArrayList.cs +++ b/Recyclable.Collections/RecyclableArrayList.cs @@ -374,7 +374,7 @@ namespace Recyclable.Collections _count = 0; } - public bool Contains(T item) => Array.IndexOf(_memoryBlock, item, 0, _count) >= 0; + public bool Contains(T item) => _count > 0 && Array.IndexOf(_memoryBlock, item, 0, _count) >= 0; public void CopyTo(T[] array, int arrayIndex) => Array.Copy(_memoryBlock, 0, array, arrayIndex, _count);