mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
AK: Read and write accumulated BitStream bits directly
This commit is contained in:
parent
424df62b00
commit
e007279315
1 changed files with 4 additions and 16 deletions
|
@ -90,11 +90,7 @@ public:
|
||||||
m_current_byte.clear();
|
m_current_byte.clear();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto temp_buffer = TRY(ByteBuffer::create_uninitialized(1));
|
m_current_byte = TRY(m_stream->read_value<u8>());
|
||||||
// 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_bit_offset = 0;
|
m_bit_offset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,13 +188,7 @@ public:
|
||||||
m_current_byte.clear();
|
m_current_byte.clear();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto temp_buffer = TRY(ByteBuffer::create_uninitialized(1));
|
m_current_byte = TRY(m_stream->read_value<u8>());
|
||||||
// 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_bit_offset = 0;
|
m_bit_offset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,8 +249,7 @@ public:
|
||||||
m_bit_offset++;
|
m_bit_offset++;
|
||||||
|
|
||||||
if (m_bit_offset > 7) {
|
if (m_bit_offset > 7) {
|
||||||
// FIXME: This should write the entire span.
|
TRY(m_stream->write_value(m_current_byte));
|
||||||
TRY(m_stream->write_some({ &m_current_byte, sizeof(m_current_byte) }));
|
|
||||||
m_bit_offset = 0;
|
m_bit_offset = 0;
|
||||||
m_current_byte = 0;
|
m_current_byte = 0;
|
||||||
}
|
}
|
||||||
|
@ -338,8 +327,7 @@ public:
|
||||||
m_bit_offset++;
|
m_bit_offset++;
|
||||||
|
|
||||||
if (m_bit_offset > 7) {
|
if (m_bit_offset > 7) {
|
||||||
// FIXME: This should write the entire span.
|
TRY(m_stream->write_value(m_current_byte));
|
||||||
TRY(m_stream->write_some({ &m_current_byte, sizeof(m_current_byte) }));
|
|
||||||
m_bit_offset = 0;
|
m_bit_offset = 0;
|
||||||
m_current_byte = 0;
|
m_current_byte = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue