From e0072793151ec3f44080219640e3d6c3144bb8f5 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Wed, 1 Mar 2023 16:13:47 +0100 Subject: [PATCH] AK: Read and write accumulated BitStream bits directly --- AK/BitStream.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/AK/BitStream.h b/AK/BitStream.h index 84e91cdeec..492ba2f180 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -90,11 +90,7 @@ public: m_current_byte.clear(); } } else { - auto temp_buffer = TRY(ByteBuffer::create_uninitialized(1)); - // FIXME: This should read the entire span. - // FIXME: This should just write into m_current_byte directly. - TRY(m_stream->read_some(temp_buffer.bytes())); - m_current_byte = temp_buffer[0]; + m_current_byte = TRY(m_stream->read_value()); m_bit_offset = 0; } } @@ -192,13 +188,7 @@ public: m_current_byte.clear(); } } else { - auto temp_buffer = TRY(ByteBuffer::create_uninitialized(1)); - // FIXME: This should read the entire span. - // FIXME: This should just write into m_current_byte directly. - auto read_bytes = TRY(m_stream->read_some(temp_buffer.bytes())); - if (read_bytes.is_empty()) - return Error::from_string_literal("eof"); - m_current_byte = temp_buffer[0]; + m_current_byte = TRY(m_stream->read_value()); m_bit_offset = 0; } } @@ -259,8 +249,7 @@ public: m_bit_offset++; if (m_bit_offset > 7) { - // FIXME: This should write the entire span. - TRY(m_stream->write_some({ &m_current_byte, sizeof(m_current_byte) })); + TRY(m_stream->write_value(m_current_byte)); m_bit_offset = 0; m_current_byte = 0; } @@ -338,8 +327,7 @@ public: m_bit_offset++; if (m_bit_offset > 7) { - // FIXME: This should write the entire span. - TRY(m_stream->write_some({ &m_current_byte, sizeof(m_current_byte) })); + TRY(m_stream->write_value(m_current_byte)); m_bit_offset = 0; m_current_byte = 0; }