@@ -157,6 +157,13 @@ public static ReadOnlySpan<char> FirstSplit(this ReadOnlySpan<char> source,
157157 return FirstSplitSpan ( source , i , splitSequence . Length , out nextIndex ) ;
158158 }
159159
160+ /// <inheritdoc cref="FirstSplit(StringSegment, StringSegment, out int, int, StringComparison)"/>
161+ public static ReadOnlySpan < char > FirstSplit ( this ReadOnlySpan < char > source ,
162+ StringSegment splitSequence ,
163+ out int nextIndex ,
164+ StringComparison comparisonType = StringComparison . Ordinal )
165+ => source . FirstSplit ( splitSequence . AsSpan ( ) , out nextIndex , comparisonType ) ;
166+
160167 /// <summary>
161168 /// Enumerates a string by segments that are separated by the split character.
162169 /// </summary>
@@ -165,8 +172,8 @@ public static ReadOnlySpan<char> FirstSplit(this ReadOnlySpan<char> source,
165172 /// <param name="options">Can specify to omit empty entries.</param>
166173 /// <returns>An enumerable of the segments.</returns>
167174 public static IEnumerable < string > SplitToEnumerable ( this string source ,
168- char splitCharacter ,
169- StringSplitOptions options = StringSplitOptions . None )
175+ char splitCharacter ,
176+ StringSplitOptions options = StringSplitOptions . None )
170177 {
171178 if ( source is null ) throw new ArgumentNullException ( nameof ( source ) ) ;
172179 Contract . EndContractBlock ( ) ;
@@ -177,7 +184,7 @@ public static IEnumerable<string> SplitToEnumerable(this string source,
177184 ? Enumerable . Repeat ( string . Empty , 1 )
178185 : SplitAsEnumerableCore ( ) ,
179186 StringSplitOptions . RemoveEmptyEntries => source . Length == 0
180- ? [ ]
187+ ? Enumerable . Empty < string > ( )
181188 : SplitAsEnumerableCoreOmitEmpty ( ) ,
182189 _ => throw new System . ComponentModel . InvalidEnumArgumentException ( ) ,
183190 } ;
@@ -232,7 +239,7 @@ public static IEnumerable<string> SplitToEnumerable(
232239 ? Enumerable . Repeat ( string . Empty , 1 )
233240 : SplitAsEnumerableCore ( source , splitSequence , comparisonType ) ,
234241 StringSplitOptions . RemoveEmptyEntries => source . Length == 0
235- ? [ ]
242+ ? Enumerable . Empty < string > ( )
236243 : SplitAsEnumerableCoreOmitEmpty ( source , splitSequence , comparisonType ) ,
237244 _ => throw new System . ComponentModel . InvalidEnumArgumentException ( ) ,
238245 } ;
@@ -277,7 +284,7 @@ public static IEnumerable<ReadOnlyMemory<char>> SplitAsMemory(
277284 ? Enumerable . Repeat ( ReadOnlyMemory < char > . Empty , 1 )
278285 : SplitAsMemoryCore ( source , splitCharacter ) ,
279286 StringSplitOptions . RemoveEmptyEntries => source . Length == 0
280- ? [ ]
287+ ? Enumerable . Empty < ReadOnlyMemory < char > > ( )
281288 : SplitAsMemoryOmitEmpty ( source , splitCharacter ) ,
282289 _ => throw new System . ComponentModel . InvalidEnumArgumentException ( ) ,
283290 } ;
@@ -325,7 +332,7 @@ public static IEnumerable<ReadOnlyMemory<char>> SplitAsMemory(this string source
325332 ? Enumerable . Repeat ( ReadOnlyMemory < char > . Empty , 1 )
326333 : SplitAsMemoryCore ( source , splitSequence , comparisonType ) ,
327334 StringSplitOptions . RemoveEmptyEntries => source . Length == 0
328- ? [ ]
335+ ? Enumerable . Empty < ReadOnlyMemory < char > > ( )
329336 : SplitAsMemoryOmitEmpty ( source , splitSequence , comparisonType ) ,
330337 _ => throw new System . ComponentModel . InvalidEnumArgumentException ( ) ,
331338 } ;
@@ -356,7 +363,7 @@ static IEnumerable<ReadOnlyMemory<char>> SplitAsMemoryCore(string source, string
356363 }
357364 }
358365
359- static readonly IReadOnlyList < string > SingleEmpty = Array . AsReadOnly ( new [ ] { string . Empty } ) ;
366+ static readonly IReadOnlyList < string > SingleEmpty = new List < string > { string . Empty } . AsReadOnly ( ) ;
360367
361368 /// <summary>
362369 /// Splits a sequence of characters into strings using the character provided.
@@ -375,7 +382,7 @@ public static IReadOnlyList<string> Split(this ReadOnlySpan<char> source,
375382 return SingleEmpty ;
376383
377384 case StringSplitOptions . RemoveEmptyEntries when source . Length == 0 :
378- return [ ] ;
385+ return Array . Empty < string > ( ) ;
379386
380387 case StringSplitOptions . RemoveEmptyEntries :
381388 {
@@ -423,7 +430,7 @@ public static IReadOnlyList<string> Split(this ReadOnlySpan<char> source,
423430 return SingleEmpty ;
424431
425432 case StringSplitOptions . RemoveEmptyEntries when source . IsEmpty :
426- return [ ] ;
433+ return Array . Empty < string > ( ) ;
427434
428435 case StringSplitOptions . RemoveEmptyEntries :
429436 {
@@ -451,4 +458,11 @@ public static IReadOnlyList<string> Split(this ReadOnlySpan<char> source,
451458 }
452459 }
453460 }
461+
462+ /// <inheritdoc cref="Split(ReadOnlySpan{char}, ReadOnlySpan{char}, StringSplitOptions, StringComparison)"/>
463+ public static IReadOnlyList < string > Split ( this ReadOnlySpan < char > source ,
464+ StringSegment splitSequence ,
465+ StringSplitOptions options = StringSplitOptions . None ,
466+ StringComparison comparisonType = StringComparison . Ordinal )
467+ => source . Split ( splitSequence . AsSpan ( ) , options , comparisonType ) ;
454468}
0 commit comments