mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibCompress: Remove unnecessary InputBitStream.
This commit is contained in:
parent
4af8eea56f
commit
49e6ff8958
Notes:
sideshowbarker
2024-07-19 02:46:19 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/49e6ff89585 Pull-request: https://github.com/SerenityOS/serenity/pull/3455
2 changed files with 5 additions and 6 deletions
|
@ -143,10 +143,10 @@ bool DeflateDecompressor::CompressedBlock::try_read_more()
|
|||
return false;
|
||||
}
|
||||
|
||||
const auto run_length = m_decompressor.decode_run_length(symbol);
|
||||
const auto length = m_decompressor.decode_length(symbol);
|
||||
const auto distance = m_decompressor.decode_distance(m_distance_codes.value().read_symbol(m_decompressor.m_input_stream));
|
||||
|
||||
for (size_t idx = 0; idx < run_length; ++idx) {
|
||||
for (size_t idx = 0; idx < length; ++idx) {
|
||||
u8 byte = 0;
|
||||
m_decompressor.m_output_stream.read({ &byte, sizeof(byte) }, distance);
|
||||
m_decompressor.m_output_stream << byte;
|
||||
|
@ -306,8 +306,7 @@ bool DeflateDecompressor::eof() const { return m_state == State::Idle && m_read_
|
|||
Optional<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes)
|
||||
{
|
||||
InputMemoryStream memory_stream { bytes };
|
||||
InputBitStream bit_stream { memory_stream };
|
||||
DeflateDecompressor deflate_stream { bit_stream };
|
||||
DeflateDecompressor deflate_stream { memory_stream };
|
||||
OutputMemoryStream output_stream;
|
||||
|
||||
u8 buffer[4096];
|
||||
|
@ -322,7 +321,7 @@ Optional<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes)
|
|||
return output_stream.copy_into_contiguous_buffer();
|
||||
}
|
||||
|
||||
u32 DeflateDecompressor::decode_run_length(u32 symbol)
|
||||
u32 DeflateDecompressor::decode_length(u32 symbol)
|
||||
{
|
||||
// FIXME: I can't quite follow the algorithm here, but it seems to work.
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
static Optional<ByteBuffer> decompress_all(ReadonlyBytes);
|
||||
|
||||
private:
|
||||
u32 decode_run_length(u32);
|
||||
u32 decode_length(u32);
|
||||
u32 decode_distance(u32);
|
||||
void decode_codes(CanonicalCode& literal_code, Optional<CanonicalCode>& distance_code);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue