@@ -130,14 +130,12 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan<char> source, Rea
130
130
}
131
131
132
132
int startIndex , endIndex , jump ;
133
- ReadOnlySpan < char > remainingSource ;
134
133
if ( fromBeginning )
135
134
{
136
135
// Left to right, from zero to last possible index in the source string.
137
136
// Incrementing by one after each iteration. Stop condition is last possible index plus 1.
138
137
startIndex = 0 ;
139
138
endIndex = source . Length - target . Length + 1 ;
140
- remainingSource = source . Slice ( endIndex ) ;
141
139
jump = 1 ;
142
140
}
143
141
else
@@ -146,7 +144,6 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan<char> source, Rea
146
144
// Decrementing by one after each iteration. Stop condition is last possible index minus 1.
147
145
startIndex = source . Length - target . Length ;
148
146
endIndex = - 1 ;
149
- remainingSource = source . Slice ( 0 , startIndex ) ;
150
147
jump = - 1 ;
151
148
}
152
149
@@ -196,6 +193,10 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan<char> source, Rea
196
193
}
197
194
198
195
// Before we return -1, check if the remaining source contains any special or non-Ascii characters.
196
+ ReadOnlySpan < char > remainingSource = fromBeginning
197
+ ? source . Slice ( endIndex )
198
+ : source . Slice ( 0 , startIndex ) ;
199
+
199
200
if ( remainingSource . ContainsAnyExcept ( s_nonSpecialAsciiChars ) )
200
201
{
201
202
goto InteropCall ;
@@ -255,14 +256,12 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan<char> source, ReadOnlySpan<
255
256
}
256
257
257
258
int startIndex , endIndex , jump ;
258
- ReadOnlySpan < char > remainingSource ;
259
259
if ( fromBeginning )
260
260
{
261
261
// Left to right, from zero to last possible index in the source string.
262
262
// Incrementing by one after each iteration. Stop condition is last possible index plus 1.
263
263
startIndex = 0 ;
264
264
endIndex = source . Length - target . Length + 1 ;
265
- remainingSource = source . Slice ( endIndex ) ;
266
265
jump = 1 ;
267
266
}
268
267
else
@@ -271,7 +270,6 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan<char> source, ReadOnlySpan<
271
270
// Decrementing by one after each iteration. Stop condition is last possible index minus 1.
272
271
startIndex = source . Length - target . Length ;
273
272
endIndex = - 1 ;
274
- remainingSource = source . Slice ( 0 , startIndex ) ;
275
273
jump = - 1 ;
276
274
}
277
275
@@ -309,12 +307,6 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan<char> source, ReadOnlySpan<
309
307
Next : ;
310
308
}
311
309
312
- // Before we return -1, check if the remaining source contains any special or non-Ascii characters.
313
- if ( remainingSource . ContainsAnyExcept ( s_nonSpecialAsciiChars ) )
314
- {
315
- goto InteropCall ;
316
- }
317
-
318
310
return - 1 ;
319
311
320
312
InteropCall :
0 commit comments