mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
LibCompress: Copy LZMA repetitions from the buffer in sequence
This improves the decompression time of `clang-15.0.7.src.tar.xz` from 5.2 seconds down to about 2.7 seconds.
This commit is contained in:
parent
b88c58b94c
commit
7000ccf89f
1 changed files with 5 additions and 14 deletions
|
@ -520,22 +520,13 @@ ErrorOr<Bytes> LzmaDecompressor::read_some(Bytes bytes)
|
||||||
if (m_options.uncompressed_size.has_value() && m_options.uncompressed_size.value() < m_total_decoded_bytes + real_length)
|
if (m_options.uncompressed_size.has_value() && m_options.uncompressed_size.value() < m_total_decoded_bytes + real_length)
|
||||||
return Error::from_string_literal("Tried to copy match beyond expected uncompressed file size");
|
return Error::from_string_literal("Tried to copy match beyond expected uncompressed file size");
|
||||||
|
|
||||||
while (real_length > 0) {
|
auto copied_length = TRY(m_dictionary->copy_from_seekback(current_repetition_offset(), real_length));
|
||||||
if (m_dictionary->empty_space() == 0) {
|
|
||||||
m_leftover_match_length = real_length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 byte;
|
m_total_decoded_bytes += copied_length;
|
||||||
auto read_bytes = TRY(m_dictionary->read_with_seekback({ &byte, sizeof(byte) }, current_repetition_offset()));
|
real_length -= copied_length;
|
||||||
VERIFY(read_bytes.size() == sizeof(byte));
|
|
||||||
|
|
||||||
auto written_bytes = m_dictionary->write({ &byte, sizeof(byte) });
|
if (real_length > 0)
|
||||||
VERIFY(written_bytes == sizeof(byte));
|
m_leftover_match_length = real_length;
|
||||||
m_total_decoded_bytes++;
|
|
||||||
|
|
||||||
real_length--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue