@@ -327,11 +327,6 @@ private struct FixedSizePriorityMap
327327 /// </summary>
328328 private const int EndOfList = - 1 ;
329329
330- /// <summary>
331- /// The index representing the negative offset for the start of the free list.
332- /// </summary>
333- private const int StartOfFreeList = - 3 ;
334-
335330 /// <summary>
336331 /// The array of 1-based indices for the <see cref="MapEntry"/> items stored in <see cref="mapEntries"/>.
337332 /// </summary>
@@ -352,11 +347,6 @@ private struct FixedSizePriorityMap
352347 /// </summary>
353348 private int count ;
354349
355- /// <summary>
356- /// The 1-based index for the start of the free list within <see cref="mapEntries"/>.
357- /// </summary>
358- private int freeList ;
359-
360350 /// <summary>
361351 /// The current incremental timestamp for the items stored in <see cref="heapEntries"/>.
362352 /// </summary>
@@ -414,7 +404,6 @@ public FixedSizePriorityMap(int capacity)
414404 this . mapEntries = new MapEntry [ capacity ] ;
415405 this . heapEntries = new HeapEntry [ capacity ] ;
416406 this . count = 0 ;
417- this . freeList = EndOfList ;
418407 this . timestamp = 0 ;
419408 }
420409
@@ -525,7 +514,6 @@ public void Reset()
525514 this . mapEntries . AsSpan ( ) . Clear ( ) ;
526515 this . heapEntries . AsSpan ( ) . Clear ( ) ;
527516 this . count = 0 ;
528- this . freeList = EndOfList ;
529517 this . timestamp = 0 ;
530518 }
531519
@@ -575,22 +563,11 @@ private unsafe void Insert(string value, int hashcode)
575563 ref HeapEntry heapEntriesRef = ref this . heapEntries . DangerousGetReference ( ) ;
576564 int entryIndex , heapIndex ;
577565
578- // If the free list is not empty, get that map node and update the field
579- if ( this . freeList != EndOfList )
580- {
581- entryIndex = this . freeList ;
582- heapIndex = this . count ;
583-
584- int nextIndex = Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) entryIndex ) . NextIndex ;
585-
586- // Update the free list pointer: either to the next free node or to the invalid marker
587- this . freeList = StartOfFreeList - nextIndex ;
588- }
589- else if ( this . count == this . mapEntries . Length )
566+ // If the current map is full, first get the oldest value, which is
567+ // always the first item in the heap. Then, free up a slot by
568+ // removing that, and insert the new value in that empty location.
569+ if ( this . count == this . mapEntries . Length )
590570 {
591- // If the current map is full, first get the oldest value, which is
592- // always the first item in the heap. Then, free up a slot by
593- // removing that, and insert the new value in that empty location.
594571 entryIndex = heapEntriesRef . MapIndex ;
595572 heapIndex = 0 ;
596573
@@ -605,6 +582,7 @@ private unsafe void Insert(string value, int hashcode)
605582 }
606583 else
607584 {
585+ // If the free list is not empty, get that map node and update the field
608586 entryIndex = this . count ;
609587 heapIndex = this . count ;
610588 }
0 commit comments