diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-03-01 16:13:47 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-13 15:16:20 +0000 |
commit | e0072793151ec3f44080219640e3d6c3144bb8f5 (patch) | |
tree | c286e31d6735ae15fc22246ea59c3d046dfe479e /AK/BitStream.h | |
parent | 424df62b00e5d7a8ac4a691ad03e369d50eff6be (diff) | |
download | serenity-e0072793151ec3f44080219640e3d6c3144bb8f5.zip |
AK: Read and write accumulated BitStream bits directly
Diffstat (limited to 'AK/BitStream.h')
-rw-r--r-- | AK/BitStream.h | 20 |
1 files 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<u8>()); 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<u8>()); 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; } |