Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CheckAndResizeBuffer()

void System.Text.Json.PooledByteBufferWriter.CheckAndResizeBuffer ( int sizeHint)
inlineprivate

Definition at line 73 of file PooledByteBufferWriter.cs.

74 {
75 if (sizeHint == 0)
76 {
77 sizeHint = 256;
78 }
79 int num = _rentedBuffer.Length - _index;
80 if (sizeHint <= num)
81 {
82 return;
83 }
84 int num2 = _rentedBuffer.Length;
85 int num3 = Math.Max(sizeHint, num2);
86 int num4 = num2 + num3;
87 if ((uint)num4 > 2147483647u)
88 {
89 num4 = num2 + sizeHint;
90 if ((uint)num4 > 2147483647u)
91 {
92 ThrowHelper.ThrowOutOfMemoryException_BufferMaximumSizeExceeded((uint)num4);
93 }
94 }
97 Span<byte> span = rentedBuffer.AsSpan(0, _index);
98 span.CopyTo(_rentedBuffer);
99 span.Clear();
101 }
static ArrayPool< T > Shared
Definition ArrayPool.cs:7

References System.Text.Json.PooledByteBufferWriter._index, System.Text.Json.PooledByteBufferWriter._rentedBuffer, System.Span< T >.CopyTo(), System.Text.Json.Dictionary, System.Math.Max(), System.Buffers.ArrayPool< T >.Shared, and System.Text.Json.ThrowHelper.ThrowOutOfMemoryException_BufferMaximumSizeExceeded().

Referenced by System.Text.Json.PooledByteBufferWriter.GetMemory(), and System.Text.Json.PooledByteBufferWriter.GetSpan().