public bool MoveNext() { var span = _str; if (span.Length == 0) { return(false); } var index = span.IndexOfAny('\r', '\n'); if (index == -1) { _str = ReadOnlySpan <char> .Empty; Current = new LineSplitEntry(span, ReadOnlySpan <char> .Empty); return(true); } if (index < span.Length - 1 && span[index] == '\r') { // Try to consume the '\n' associated to the '\r' var next = span[index + 1]; if (next == '\n') { Current = new LineSplitEntry(span[..index], span.Slice(index, 2));
public bool MoveNext() { var span = _str; if (span.Length == 0) // Reach the end of the string { return(false); } var index = span.IndexOfAny('\r', '\n'); if (index == -1) // The string is composed of only one line { _str = ReadOnlySpan <char> .Empty; // The remaining string is an empty string Current = new LineSplitEntry(span, ReadOnlySpan <char> .Empty); return(true); } if (index < span.Length - 1 && span[index] == '\r') { // Try to consume the '\n' associated to the '\r' var next = span[index + 1]; if (next == '\n') { Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 2)); _str = span.Slice(index + 2); return(true); } } Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 1)); _str = span.Slice(index + 1); return(true); }
public bool MoveNext() { if (_str.Length == 0) { return(false); } var span = _str; var index = span.IndexOfAny('\r', '\n'); if (index == -1) { _str = ReadOnlySpan <char> .Empty; Current = new LineSplitEntry(span, ReadOnlySpan <char> .Empty); return(true); } if (index < span.Length - 1 && span[index] == '\r') { var next = span[index + 1]; if (next == '\n') { Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 2)); _str = span.Slice(index + 2); return(true); } } Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 1)); _str = span.Slice(index + 1); return(true); }
public bool MoveNext() { if (_str.Length == 0) { return(false); } var span = _str; var index = span.IndexOfAny('\r', '\n'); /* Unmerged change from project 'Meziantou.Analyzer (netstandard2.0)' * Before: * if (index == -1) * { * _str = ReadOnlySpan<char>.Empty; * After: * if (index == -1) * { * _str = ReadOnlySpan<char>.Empty; */ if (index == -1) { _str = ReadOnlySpan <char> .Empty; Current = new LineSplitEntry(span, ReadOnlySpan <char> .Empty); return(true); } if (index < span.Length - 1 && span[index] == '\r') { var next = span[index + 1]; if (next == '\n') { Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 2)); _str = span.Slice(index + 2); return(true); } } Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 1)); _str = span.Slice(index + 1); return(true); }
public bool MoveNext() { var span = _span; if (span.Length == 0) // Reach the end of the string { return(false); } var index = span.IndexOf(CRLF_Bytes); if (index == -1) // The string is composed of only one line { _span = ReadOnlySpan <byte> .Empty; // The remaining string is an empty string Current = new LineSplitEntry(span, ReadOnlySpan <byte> .Empty); return(true); } else { Current = new LineSplitEntry(span.Slice(0, index), span.Slice(index, 2)); _span = span.Slice(index + 2); return(true); } }
public bool MoveNext() { ReadOnlySpan <T> span = _span; // Reach the end of the string if (span.Length == 0) { return(false); } int index = span.IndexOfAny(_separators); if (index == -1) // The string doesn't contain the separators { _span = ReadOnlySpan <T> .Empty; // The remaining string is an empty string Current = new LineSplitEntry <T>(span, ReadOnlySpan <T> .Empty); return(true); } for (var i = 0; i < _separators.Length; i++) { T c = _separators[i]; if (index < span.Length - 1 && span[index].Equals(c)) { // Try to consume the char associated to the next char T next = span[index + 1]; if (i + 1 >= _separators.Length) { continue; } if (next.Equals(_separators[i + 1])) { Current = new LineSplitEntry <T>(span[..index], span.Slice(index, 2));
public LineSplitEnumerator(ReadOnlySpan <byte> span) { _span = span; Current = default; }