File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,10 @@ public bool MoveNext()
73
73
{
74
74
this . start = newEnd ;
75
75
76
- int index = this . span . Slice ( newEnd ) . IndexOf ( this . separator ) ;
76
+ // Here we're inside the 'CommunityToolkit.HighPerformance.Enumerables' namespace, so the
77
+ // 'MemoryExtensions' type from the .NET Community Toolkit would be bound instead. Because
78
+ // want the one from the BCL (to search by value), we can use its fully qualified name.
79
+ int index = System . MemoryExtensions . IndexOf ( this . span . Slice ( newEnd ) , this . separator ) ;
77
80
78
81
// Extract the current subsequence
79
82
if ( index >= 0 )
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ public static ReadOnlySpan2D<T> AsSpan2D<T>(this ReadOnlySpan<T> span, int offse
210
210
/// <param name="value">The reference to the target item to get the index for.</param>
211
211
/// <returns>The index of <paramref name="value"/> within <paramref name="span"/>, or <c>-1</c>.</returns>
212
212
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
213
- public static unsafe int IndexOf < T > ( this ReadOnlySpan < T > span , in T value )
213
+ public static unsafe int IndexOf < T > ( this ReadOnlySpan < T > span , ref readonly T value )
214
214
{
215
215
ref T r0 = ref MemoryMarshal . GetReference ( span ) ;
216
216
ref T r1 = ref Unsafe . AsRef ( in value ) ;
Original file line number Diff line number Diff line change @@ -148,10 +148,15 @@ public static Span<TTo> Cast<TFrom, TTo>(this Span<TFrom> span)
148
148
/// <param name="value">The reference to the target item to get the index for.</param>
149
149
/// <returns>The index of <paramref name="value"/> within <paramref name="span"/>, or <c>-1</c>.</returns>
150
150
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
151
- public static unsafe int IndexOf < T > ( this Span < T > span , ref T value )
151
+ public static unsafe int IndexOf < T > ( this Span < T > span , ref readonly T value )
152
152
{
153
153
ref T r0 = ref MemoryMarshal . GetReference ( span ) ;
154
- IntPtr byteOffset = Unsafe . ByteOffset ( ref r0 , ref value ) ;
154
+ IntPtr byteOffset =
155
+ #if NET8_0_OR_GREATER
156
+ Unsafe . ByteOffset ( ref r0 , in value ) ;
157
+ #else
158
+ Unsafe . ByteOffset ( ref r0 , ref Unsafe . AsRef ( in value ) ) ;
159
+ #endif
155
160
156
161
nint elementOffset = byteOffset / ( nint ) ( uint ) sizeof ( T ) ;
157
162
You can’t perform that action at this time.
0 commit comments