3 writes to _buffer
System.Text.Json (3)
System\Text\Json\Serialization\StreamReadBufferState.cs (3)
46
_buffer
= ArrayPool<byte>.Shared.Rent(Math.Max(initialBufferSize, JsonConstants.Utf8Bom.Length));
141
_buffer
= newBuffer;
185
_buffer
= null!;
15 references to _buffer
System.Text.Json (15)
System\Text\Json\Serialization\StreamReadBufferState.cs (15)
54
public readonly ReadOnlySequence<byte> Bytes => new(
_buffer
.AsMemory(_offset, _count));
69
int minBufferCount = fillBuffer || _unsuccessfulReadCount > UnsuccessfulReadCountThreshold ? bufferState.
_buffer
.Length : 0;
72
int bytesRead = await stream.ReadAsync(bufferState.
_buffer
.AsMemory(bufferState._count), cancellationToken).ConfigureAwait(false);
99
_buffer
.AsSpan(_count));
112
while (_count <
_buffer
.Length);
132
if ((uint)_count > ((uint)
_buffer
.Length / 2))
135
byte[] oldBuffer =
_buffer
;
137
byte[] newBuffer = ArrayPool<byte>.Shared.Rent((
_buffer
.Length < (int.MaxValue / 2)) ?
_buffer
.Length * 2 : int.MaxValue);
151
Buffer.BlockCopy(
_buffer
, _offset + bytesConsumedInt,
_buffer
, 0, _count);
170
Debug.Assert(
_buffer
.Length >= JsonConstants.Utf8Bom.Length);
171
if (
_buffer
.AsSpan(0, _count).StartsWith(JsonConstants.Utf8Bom))
182
new Span<byte>(
_buffer
, 0, _maxCount).Clear();
184
byte[] toReturn =
_buffer
;