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

◆ ReadBuffer() [2/2]

int System.IO.StreamReader.ReadBuffer ( Span< char > userBuffer,
out bool readToUserBuffer )
inlineprivate

Definition at line 580 of file StreamReader.cs.

581 {
582 _charLen = 0;
583 _charPos = 0;
584 if (!_checkPreamble)
585 {
586 _byteLen = 0;
587 }
588 int num = 0;
589 readToUserBuffer = userBuffer.Length >= _maxCharsPerBuffer;
590 do
591 {
592 if (_checkPreamble)
593 {
594 int num2 = _stream.Read(_byteBuffer, _bytePos, _byteBuffer.Length - _bytePos);
595 if (num2 == 0)
596 {
597 if (_byteLen > 0)
598 {
599 if (readToUserBuffer)
600 {
601 num = _decoder.GetChars(new ReadOnlySpan<byte>(_byteBuffer, 0, _byteLen), userBuffer.Slice(num), flush: false);
602 _charLen = 0;
603 }
604 else
605 {
607 _charLen += num;
608 }
609 }
610 return num;
611 }
612 _byteLen += num2;
613 }
614 else
615 {
617 if (_byteLen == 0)
618 {
619 break;
620 }
621 }
623 if (!IsPreamble())
624 {
625 if (_detectEncoding && _byteLen >= 2)
626 {
628 readToUserBuffer = userBuffer.Length >= _maxCharsPerBuffer;
629 }
630 _charPos = 0;
631 if (readToUserBuffer)
632 {
633 num += _decoder.GetChars(new ReadOnlySpan<byte>(_byteBuffer, 0, _byteLen), userBuffer.Slice(num), flush: false);
634 _charLen = 0;
635 }
636 else
637 {
639 _charLen += num;
640 }
641 }
642 }
643 while (num == 0);
644 _isBlocked &= num < userBuffer.Length;
645 return num;
646 }
readonly Stream _stream
readonly byte[] _byteBuffer
int Read(byte[] buffer, int offset, int count)
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
Span< T > Slice(int start)
Definition Span.cs:271
int Length
Definition Span.cs:70

References System.IO.StreamReader._byteBuffer, System.IO.StreamReader._byteLen, System.IO.StreamReader._bytePos, System.IO.StreamReader._charBuffer, System.IO.StreamReader._charLen, System.IO.StreamReader._charPos, System.IO.StreamReader._checkPreamble, System.IO.StreamReader._decoder, System.IO.StreamReader._detectEncoding, System.IO.StreamReader._isBlocked, System.IO.StreamReader._maxCharsPerBuffer, System.IO.StreamReader._stream, System.IO.StreamReader.DetectEncoding(), System.Text.Decoder.GetChars(), System.IO.StreamReader.IsPreamble(), System.Span< T >.Length, System.IO.Stream.Read(), and System.Span< T >.Slice().