From 7319deb03d6f2c44ba48fc01b8f8a44335478cd0 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 29 Mar 2023 20:30:55 -0400 Subject: [PATCH] AK: Remove BitStream workaround for now-resolved BufferedStream behavior The issue was that the buffer would only be filled if it was empty. --- AK/BitStream.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/AK/BitStream.h b/AK/BitStream.h index df7bdd1f5f..373e6a2447 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -234,19 +234,10 @@ private: size_t bytes_to_read = bits_to_read / bits_per_byte; BufferType buffer = 0; - - Bytes bytes { &buffer, bytes_to_read }; - size_t bytes_read = 0; - - // FIXME: When the underlying stream is buffered, `read_some` seems to stop before EOF. - do { - auto result = TRY(m_stream->read_some(bytes)); - bytes = bytes.slice(result.size()); - bytes_read += result.size(); - } while (!bytes.is_empty() && !m_stream->is_eof()); + auto bytes = TRY(m_stream->read_some({ &buffer, bytes_to_read })); m_bit_buffer = (buffer << m_bit_count) | lsb_aligned_buffer(); - m_bit_count += bytes_read * bits_per_byte; + m_bit_count += bytes.size() * bits_per_byte; m_bit_offset = 0; return {};