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

◆ Read() [2/2]

override int System.Text.TranscodingStream.Read ( Span< byte > buffer)
inlinevirtual

Reimplemented from System.IO.Stream.

Definition at line 220 of file TranscodingStream.cs.

221 {
223 if (_readBufferCount == 0)
224 {
225 byte[] array = ArrayPool<byte>.Shared.Rent(4096);
226 char[] array2 = ArrayPool<char>.Shared.Rent(_readCharBufferMaxSize);
227 try
228 {
229 bool flag;
230 int bytes;
231 do
232 {
233 int num = _innerStream.Read(array, 0, 4096);
234 flag = num == 0;
235 int chars = _innerDecoder.GetChars(array, 0, num, array2, 0, flag);
236 bytes = _thisEncoder.GetBytes(array2, 0, chars, _readBuffer, 0, flag);
237 }
238 while (!flag && bytes == 0);
241 }
242 finally
243 {
245 ArrayPool<char>.Shared.Return(array2);
246 }
247 }
248 int num2 = Math.Min(_readBufferCount, buffer.Length);
249 _readBuffer.AsSpan(_readBufferOffset, num2).CopyTo(buffer);
250 _readBufferOffset += num2;
251 _readBufferCount -= num2;
252 return num2;
253 }
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
int Read(byte[] buffer, int offset, int count)
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)

References System.Text.TranscodingStream._innerDecoder, System.Text.TranscodingStream._innerStream, System.Text.TranscodingStream._readBuffer, System.Text.TranscodingStream._readBufferCount, System.Text.TranscodingStream._readBufferOffset, System.Text.TranscodingStream._readCharBufferMaxSize, System.Text.TranscodingStream._thisEncoder, System.array, System.buffer, System.bytes, System.chars, System.Text.TranscodingStream.EnsurePreReadConditions(), System.Text.Encoder.GetBytes(), System.Text.Decoder.GetChars(), System.Math.Min(), System.IO.Stream.Read(), and System.Buffers.ArrayPool< T >.Shared.