From c363c354fd7d87a7ec0a100dd4f2e055f2f02cfd Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 22 Apr 2025 19:17:02 +0500 Subject: [PATCH] Remove redundant 'freeList' field --- .../System/Linq/Parallel/Utils/HashLookup.cs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/HashLookup.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/HashLookup.cs index 08ac4fa0995abf..f70eb86911d789 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/HashLookup.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/HashLookup.cs @@ -22,7 +22,6 @@ internal sealed class HashLookup private int[] buckets; private Slot[] slots; private int count; - private int freeList; private readonly IEqualityComparer? comparer; private const int HashCodeMask = 0x7fffffff; @@ -36,7 +35,6 @@ internal HashLookup(IEqualityComparer? comparer) this.comparer = comparer; buckets = new int[7]; slots = new Slot[7]; - freeList = -1; } // If value is not in set, add it and return true; otherwise return false @@ -97,18 +95,10 @@ private bool Find(TKey key, bool add, bool set, [MaybeNullWhen(false)] ref TValu if (add) { - int index; - if (freeList >= 0) - { - index = freeList; - freeList = slots[index].next; - } - else - { - if (count == slots.Length) Resize(); - index = count; - count++; - } + if (count == slots.Length) Resize(); + + int index = count; + count++; int bucket = hashCode % buckets.Length; slots[index].hashCode = hashCode;