@@ -5822,7 +5822,7 @@ private static bool TryWrite<TArg0, TArg1, TArg2>(Span<char> destination, IForma
5822
5822
public ref struct SpanSplitEnumerator < T > where T : IEquatable < T >
5823
5823
{
5824
5824
/// <summary>The input span being split.</summary>
5825
- private readonly ReadOnlySpan < T > _span ;
5825
+ private readonly ReadOnlySpan < T > _source ;
5826
5826
5827
5827
/// <summary>A single separator to use when <see cref="_splitMode"/> is <see cref="SpanSplitEnumeratorMode.SingleElement"/>.</summary>
5828
5828
private readonly T _separator = default ! ;
@@ -5836,25 +5836,29 @@ private static bool TryWrite<TArg0, TArg1, TArg2>(Span<char> destination, IForma
5836
5836
5837
5837
/// <summary>Mode that dictates how the instance was configured and how its fields should be used in <see cref="MoveNext"/>.</summary>
5838
5838
private SpanSplitEnumeratorMode _splitMode ;
5839
- /// <summary>The inclusive starting index in <see cref="_span "/> of the current range.</summary>
5839
+ /// <summary>The inclusive starting index in <see cref="_source "/> of the current range.</summary>
5840
5840
private int _startCurrent = 0 ;
5841
- /// <summary>The exclusive ending index in <see cref="_span "/> of the current range.</summary>
5841
+ /// <summary>The exclusive ending index in <see cref="_source "/> of the current range.</summary>
5842
5842
private int _endCurrent = 0 ;
5843
- /// <summary>The index in <see cref="_span "/> from which the next separator search should start.</summary>
5843
+ /// <summary>The index in <see cref="_source "/> from which the next separator search should start.</summary>
5844
5844
private int _startNext = 0 ;
5845
5845
5846
5846
/// <summary>Gets an enumerator that allows for iteration over the split span.</summary>
5847
5847
/// <returns>Returns a <see cref="SpanSplitEnumerator{T}"/> that can be used to iterate over the split span.</returns>
5848
5848
public SpanSplitEnumerator < T > GetEnumerator ( ) => this ;
5849
5849
5850
+ /// <summary>Gets the source span being enumerated.</summary>
5851
+ /// <returns>Returns the <see cref="ReadOnlySpan{T}"/> that was provided when creating this enumerator.</returns>
5852
+ public readonly ReadOnlySpan < T > Source => _source ;
5853
+
5850
5854
/// <summary>Gets the current element of the enumeration.</summary>
5851
5855
/// <returns>Returns a <see cref="Range"/> instance that indicates the bounds of the current element withing the source span.</returns>
5852
5856
public Range Current => new Range ( _startCurrent , _endCurrent ) ;
5853
5857
5854
5858
/// <summary>Initializes the enumerator for <see cref="SpanSplitEnumeratorMode.SearchValues"/>.</summary>
5855
- internal SpanSplitEnumerator ( ReadOnlySpan < T > span , SearchValues < T > searchValues )
5859
+ internal SpanSplitEnumerator ( ReadOnlySpan < T > source , SearchValues < T > searchValues )
5856
5860
{
5857
- _span = span ;
5861
+ _source = source ;
5858
5862
_splitMode = SpanSplitEnumeratorMode . SearchValues ;
5859
5863
_searchValues = searchValues ;
5860
5864
}
@@ -5865,9 +5869,9 @@ internal SpanSplitEnumerator(ReadOnlySpan<T> span, SearchValues<T> searchValues)
5865
5869
/// it will instead use <see cref="SpanSplitEnumeratorMode.SearchValues"/> with a cached <see cref="SearchValues{Char}"/>
5866
5870
/// for all whitespace characters.
5867
5871
/// </remarks>
5868
- internal SpanSplitEnumerator ( ReadOnlySpan < T > span , ReadOnlySpan < T > separators )
5872
+ internal SpanSplitEnumerator ( ReadOnlySpan < T > source , ReadOnlySpan < T > separators )
5869
5873
{
5870
- _span = span ;
5874
+ _source = source ;
5871
5875
if ( typeof ( T ) == typeof ( char ) && separators . Length == 0 )
5872
5876
{
5873
5877
_searchValues = Unsafe . As < SearchValues < T > > ( string . SearchValuesStorage . WhiteSpaceChars ) ;
@@ -5882,21 +5886,21 @@ internal SpanSplitEnumerator(ReadOnlySpan<T> span, ReadOnlySpan<T> separators)
5882
5886
5883
5887
/// <summary>Initializes the enumerator for <see cref="SpanSplitEnumeratorMode.Sequence"/> (or <see cref="SpanSplitEnumeratorMode.EmptySequence"/> if the separator is empty).</summary>
5884
5888
/// <remarks><paramref name="treatAsSingleSeparator"/> must be true.</remarks>
5885
- internal SpanSplitEnumerator ( ReadOnlySpan < T > span , ReadOnlySpan < T > separator , bool treatAsSingleSeparator )
5889
+ internal SpanSplitEnumerator ( ReadOnlySpan < T > source , ReadOnlySpan < T > separator , bool treatAsSingleSeparator )
5886
5890
{
5887
5891
Debug . Assert ( treatAsSingleSeparator , "Should only ever be called as true; exists to differentiate from separators overload" ) ;
5888
5892
5889
- _span = span ;
5893
+ _source = source ;
5890
5894
_separatorBuffer = separator ;
5891
5895
_splitMode = separator . Length == 0 ?
5892
5896
SpanSplitEnumeratorMode . EmptySequence :
5893
5897
SpanSplitEnumeratorMode . Sequence ;
5894
5898
}
5895
5899
5896
5900
/// <summary>Initializes the enumerator for <see cref="SpanSplitEnumeratorMode.SingleElement"/>.</summary>
5897
- internal SpanSplitEnumerator ( ReadOnlySpan < T > span , T separator )
5901
+ internal SpanSplitEnumerator ( ReadOnlySpan < T > source , T separator )
5898
5902
{
5899
- _span = span ;
5903
+ _source = source ;
5900
5904
_separator = separator ;
5901
5905
_splitMode = SpanSplitEnumeratorMode . SingleElement ;
5902
5906
}
@@ -5915,17 +5919,17 @@ public bool MoveNext()
5915
5919
return false ;
5916
5920
5917
5921
case SpanSplitEnumeratorMode . SingleElement :
5918
- separatorIndex = _span . Slice ( _startNext ) . IndexOf ( _separator ) ;
5922
+ separatorIndex = _source . Slice ( _startNext ) . IndexOf ( _separator ) ;
5919
5923
separatorLength = 1 ;
5920
5924
break ;
5921
5925
5922
5926
case SpanSplitEnumeratorMode . Any :
5923
- separatorIndex = _span . Slice ( _startNext ) . IndexOfAny ( _separatorBuffer ) ;
5927
+ separatorIndex = _source . Slice ( _startNext ) . IndexOfAny ( _separatorBuffer ) ;
5924
5928
separatorLength = 1 ;
5925
5929
break ;
5926
5930
5927
5931
case SpanSplitEnumeratorMode . Sequence :
5928
- separatorIndex = _span . Slice ( _startNext ) . IndexOf ( _separatorBuffer ) ;
5932
+ separatorIndex = _source . Slice ( _startNext ) . IndexOf ( _separatorBuffer ) ;
5929
5933
separatorLength = _separatorBuffer . Length ;
5930
5934
break ;
5931
5935
@@ -5936,7 +5940,7 @@ public bool MoveNext()
5936
5940
5937
5941
default :
5938
5942
Debug . Assert ( _splitMode == SpanSplitEnumeratorMode . SearchValues , $ "Unknown split mode: { _splitMode } ") ;
5939
- separatorIndex = _span . Slice ( _startNext ) . IndexOfAny ( _searchValues ) ;
5943
+ separatorIndex = _source . Slice ( _startNext ) . IndexOfAny ( _searchValues ) ;
5940
5944
separatorLength = 1 ;
5941
5945
break ;
5942
5946
}
@@ -5949,7 +5953,7 @@ public bool MoveNext()
5949
5953
}
5950
5954
else
5951
5955
{
5952
- _startNext = _endCurrent = _span . Length ;
5956
+ _startNext = _endCurrent = _source . Length ;
5953
5957
5954
5958
// Set _splitMode to None so that subsequent MoveNext calls will return false.
5955
5959
_splitMode = SpanSplitEnumeratorMode . None ;
0 commit comments