AK: Refill a BufferedStream when it has less than the requested size

We currently only fill a buffer when it is empty. So if it has 1 byte
and 16 KB was requested, only that 1 byte would be returned. Instead,
attempt to refill the buffer when it's size is less than the requested
size.
This commit is contained in:
Timothy Flynn 2023-03-29 20:28:37 -04:00 committed by Andreas Kling
parent 5c38b14045
commit 13573a6c4b
Notes: sideshowbarker 2024-07-17 07:16:27 +09:00

View File

@ -67,7 +67,7 @@ public:
return buffer;
// Fill the internal buffer if it has run dry.
if (m_buffer.used_space() == 0)
if (m_buffer.used_space() < buffer.size())
TRY(populate_read_buffer());
// Let's try to take all we can from the buffer first.