From 7a9284201728ab08af7b2e2c663eb4c8f5cc4c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Fri, 14 Jan 2022 01:14:24 +0100 Subject: [PATCH] LibCore: Populate the read buffer of Core::Stream::BufferedHelper Previously, we weren't ever populating the read buffer in read(), which was making the BufferedHelper useless, how silly :^). This introduces a buffer refill when we have run out of buffered samples, restoring FlacLoader performance from the new low of 200% (directly before this commit) to the old level of ~1400%. --- Userland/Libraries/LibCore/Stream.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h index 15b4f07cb2..241a324d6c 100644 --- a/Userland/Libraries/LibCore/Stream.h +++ b/Userland/Libraries/LibCore/Stream.h @@ -522,6 +522,11 @@ public: // Otherwise, let's try an extra read just in case there's something // in our receive buffer. auto stream_nread = TRY(stream().read(buffer.slice(buffer_nread))); + + // Fill the internal buffer if it has run dry. + if (m_buffered_size == 0) + TRY(populate_read_buffer()); + return buffer_nread + stream_nread; }