@@ -536,7 +536,7 @@ private unsafe ref string TryGet(ReadOnlySpan<char> span, int hashcode)
536536 ( uint ) i < ( uint ) length ;
537537 i = entry . NextIndex )
538538 {
539- entry = ref Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) i ) ;
539+ entry = ref Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) i ) ;
540540
541541 if ( entry . HashCode == hashcode &&
542542 entry . Value ! . AsSpan ( ) . SequenceEqual ( span ) )
@@ -556,7 +556,7 @@ private unsafe ref string TryGet(ReadOnlySpan<char> span, int hashcode)
556556 /// <param name="value">The new <see cref="string"/> instance to store.</param>
557557 /// <param name="hashcode">The precomputed hashcode for <paramref name="value"/>.</param>
558558 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
559- private unsafe void Insert ( string value , int hashcode )
559+ private void Insert ( string value , int hashcode )
560560 {
561561 ref int bucketsRef = ref this . buckets . DangerousGetReference ( ) ;
562562 ref MapEntry mapEntriesRef = ref this . mapEntries . DangerousGetReference ( ) ;
@@ -571,7 +571,7 @@ private unsafe void Insert(string value, int hashcode)
571571 entryIndex = heapEntriesRef . MapIndex ;
572572 heapIndex = 0 ;
573573
574- ref MapEntry removedEntry = ref Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) entryIndex ) ;
574+ ref MapEntry removedEntry = ref Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) entryIndex ) ;
575575
576576 // The removal logic can be extremely optimized in this case, as we
577577 // can retrieve the precomputed hashcode for the target entry by doing
@@ -588,9 +588,9 @@ private unsafe void Insert(string value, int hashcode)
588588 }
589589
590590 int bucketIndex = hashcode & ( this . buckets . Length - 1 ) ;
591- ref int targetBucket = ref Unsafe . Add ( ref bucketsRef , ( IntPtr ) ( void * ) ( uint ) bucketIndex ) ;
592- ref MapEntry targetMapEntry = ref Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) entryIndex ) ;
593- ref HeapEntry targetHeapEntry = ref Unsafe . Add ( ref heapEntriesRef , ( IntPtr ) ( void * ) ( uint ) heapIndex ) ;
591+ ref int targetBucket = ref Unsafe . Add ( ref bucketsRef , ( nint ) ( uint ) bucketIndex ) ;
592+ ref MapEntry targetMapEntry = ref Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) entryIndex ) ;
593+ ref HeapEntry targetHeapEntry = ref Unsafe . Add ( ref heapEntriesRef , ( nint ) ( uint ) heapIndex ) ;
594594
595595 // Assign the values in the new map entry
596596 targetMapEntry . HashCode = hashcode ;
@@ -616,7 +616,7 @@ private unsafe void Insert(string value, int hashcode)
616616 /// <param name="mapIndex">The index of the target map node to remove.</param>
617617 /// <remarks>The input <see cref="string"/> instance needs to already exist in the map.</remarks>
618618 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
619- private unsafe void Remove ( int hashcode , int mapIndex )
619+ private void Remove ( int hashcode , int mapIndex )
620620 {
621621 ref MapEntry mapEntriesRef = ref this . mapEntries . DangerousGetReference ( ) ;
622622 int
@@ -628,15 +628,15 @@ private unsafe void Remove(int hashcode, int mapIndex)
628628 // value we're looking for is guaranteed to be present
629629 while ( true )
630630 {
631- ref MapEntry candidate = ref Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) entryIndex ) ;
631+ ref MapEntry candidate = ref Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) entryIndex ) ;
632632
633633 // Check the current value for a match
634634 if ( entryIndex == mapIndex )
635635 {
636636 // If this was not the first list node, update the parent as well
637637 if ( lastIndex != EndOfList )
638638 {
639- ref MapEntry lastEntry = ref Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) lastIndex ) ;
639+ ref MapEntry lastEntry = ref Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) lastIndex ) ;
640640
641641 lastEntry . NextIndex = candidate . NextIndex ;
642642 }
@@ -662,14 +662,14 @@ private unsafe void Remove(int hashcode, int mapIndex)
662662 /// </summary>
663663 /// <param name="heapIndex">The index of the target heap node to update.</param>
664664 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
665- private unsafe void UpdateTimestamp ( ref int heapIndex )
665+ private void UpdateTimestamp ( ref int heapIndex )
666666 {
667667 int
668668 currentIndex = heapIndex ,
669669 count = this . count ;
670670 ref MapEntry mapEntriesRef = ref this . mapEntries . DangerousGetReference ( ) ;
671671 ref HeapEntry heapEntriesRef = ref this . heapEntries . DangerousGetReference ( ) ;
672- ref HeapEntry root = ref Unsafe . Add ( ref heapEntriesRef , ( IntPtr ) ( void * ) ( uint ) currentIndex ) ;
672+ ref HeapEntry root = ref Unsafe . Add ( ref heapEntriesRef , ( nint ) ( uint ) currentIndex ) ;
673673 uint timestamp = this . timestamp ;
674674
675675 // Check if incrementing the current timestamp for the heap node to update
@@ -721,7 +721,7 @@ private unsafe void UpdateTimestamp(ref int heapIndex)
721721 // Check and update the left child, if necessary
722722 if ( left < count )
723723 {
724- ref HeapEntry child = ref Unsafe . Add ( ref heapEntriesRef , ( IntPtr ) ( void * ) ( uint ) left ) ;
724+ ref HeapEntry child = ref Unsafe . Add ( ref heapEntriesRef , ( nint ) ( uint ) left ) ;
725725
726726 if ( child . Timestamp < minimum . Timestamp )
727727 {
@@ -733,7 +733,7 @@ private unsafe void UpdateTimestamp(ref int heapIndex)
733733 // Same check as above for the right child
734734 if ( right < count )
735735 {
736- ref HeapEntry child = ref Unsafe . Add ( ref heapEntriesRef , ( IntPtr ) ( void * ) ( uint ) right ) ;
736+ ref HeapEntry child = ref Unsafe . Add ( ref heapEntriesRef , ( nint ) ( uint ) right ) ;
737737
738738 if ( child . Timestamp < minimum . Timestamp )
739739 {
@@ -752,8 +752,8 @@ private unsafe void UpdateTimestamp(ref int heapIndex)
752752 }
753753
754754 // Update the indices in the respective map entries (accounting for the swap)
755- Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) root . MapIndex ) . HeapIndex = targetIndex ;
756- Unsafe . Add ( ref mapEntriesRef , ( IntPtr ) ( void * ) ( uint ) minimum . MapIndex ) . HeapIndex = currentIndex ;
755+ Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) root . MapIndex ) . HeapIndex = targetIndex ;
756+ Unsafe . Add ( ref mapEntriesRef , ( nint ) ( uint ) minimum . MapIndex ) . HeapIndex = currentIndex ;
757757
758758 currentIndex = targetIndex ;
759759
@@ -764,7 +764,7 @@ private unsafe void UpdateTimestamp(ref int heapIndex)
764764 minimum = temp ;
765765
766766 // Update the reference to the root node
767- root = ref Unsafe . Add ( ref heapEntriesRef , ( IntPtr ) ( void * ) ( uint ) currentIndex ) ;
767+ root = ref Unsafe . Add ( ref heapEntriesRef , ( nint ) ( uint ) currentIndex ) ;
768768 }
769769
770770 Fallback :
@@ -787,14 +787,14 @@ private unsafe void UpdateTimestamp(ref int heapIndex)
787787 /// a given number of nodes, those are all contiguous from the start of the array.
788788 /// </summary>
789789 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
790- private unsafe void UpdateAllTimestamps ( )
790+ private void UpdateAllTimestamps ( )
791791 {
792792 int count = this . count ;
793793 ref HeapEntry heapEntriesRef = ref this . heapEntries . DangerousGetReference ( ) ;
794794
795795 for ( int i = 0 ; i < count ; i ++ )
796796 {
797- Unsafe . Add ( ref heapEntriesRef , ( IntPtr ) ( void * ) ( uint ) i ) . Timestamp = ( uint ) i ;
797+ Unsafe . Add ( ref heapEntriesRef , ( nint ) ( uint ) i ) . Timestamp = ( uint ) i ;
798798 }
799799 }
800800 }
0 commit comments