4 writes to _lineOffset
Microsoft.Extensions.AI.OpenAI (4)
src\Shared\ServerSentEvents\SseParser_1.cs (4)
153
_lineOffset
+= advance;
233
_lineOffset
+= advance;
319
_lineOffset
= 0;
552
_lineOffset
+= 3;
22 references to _lineOffset
Microsoft.Extensions.AI.OpenAI (22)
src\Shared\ServerSentEvents\SseParser_1.cs (22)
71
/// <summary>The length of valid data in <see cref="_lineBuffer"/>, starting from <see cref="
_lineOffset
"/>.</summary>
143
_newlineIndex -
_lineOffset
+ 1 < _lineLength || // we must have CR and we have whatever comes after it
163
_lastSearchedForNewline =
_lineOffset
+ _lineLength;
223
_newlineIndex -
_lineOffset
+ 1 < _lineLength || // newline is CR, and we have whatever comes after it
271
if (_lastSearchedForNewline >
_lineOffset
)
274
searchLength = _lineLength - (_lastSearchedForNewline -
_lineOffset
);
278
searchOffset =
_lineOffset
;
282
Debug.Assert(searchOffset >=
_lineOffset
, $"{searchOffset}, {_lineLength}");
283
Debug.Assert(searchOffset <=
_lineOffset
+ _lineLength, $"{searchOffset}, {
_lineOffset
}, {_lineLength}");
292
Debug.Assert(_newlineIndex -
_lineOffset
< _lineLength, "Expected to be positioned at a non-empty newline");
293
return _lineBuffer.AsSpan(_newlineIndex, _lineLength - (_newlineIndex -
_lineOffset
)).StartsWith(CRLF) ? 2 : 1;
309
if (
_lineOffset
+ _lineLength == _lineBuffer.Length)
311
if (
_lineOffset
!= 0)
313
_lineBuffer.AsSpan(
_lineOffset
, _lineLength).CopyTo(_lineBuffer);
316
_lastSearchedForNewline -=
_lineOffset
;
334
ReadOnlySpan<byte> line = _lineBuffer.AsSpan(
_lineOffset
, _newlineIndex -
_lineOffset
);
494
int offset =
_lineOffset
+ _lineLength;
520
int offset =
_lineOffset
+ _lineLength;
548
Debug.Assert(
_lineOffset
== 0, $"Expected _lineOffset == 0, got {
_lineOffset
}");