From 5e5b6b026f37c1f104a0b4dfa69dc0a6883d49bf Mon Sep 17 00:00:00 2001 From: Lexikos Date: Sun, 20 Nov 2016 18:32:15 +1000 Subject: [PATCH] Improved buffer utilisation when File.Read() reaches end of buffer. --- source/TextIO.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/TextIO.cpp b/source/TextIO.cpp index ee0e9f1bb..5b2e7b59e 100644 --- a/source/TextIO.cpp +++ b/source/TextIO.cpp @@ -336,7 +336,14 @@ DWORD TextStream::Read(LPTSTR aBuf, DWORD aBufLen, int aNumLines) aBuf[target_used++] = INVALID_CHAR; } } // end for-loop which processes buffered data. - mPos = src; + if (src == src_end) + { + // Reset the buffer so that Read() can read a full block. + mLength = 0; + mPos = NULL; + } + else + mPos = src; } // end for-loop which repopulates the buffer. if (target_used < aBufLen) aBuf[target_used] = '\0';