1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 11:05:08 +00:00
serenity/Userland/Libraries/LibCompress
Timothy Flynn eed956b473 AK: Increase LittleEndianOutputBitStream's buffer size and remove loops
This is very similar to the LittleEndianInputBitStream bit buffer change
from 8e834d4bb2.

We currently buffer one byte of data for the underlying stream. And when
we put bits onto that buffer, we do so 1 bit at a time.

This replaces the u8 buffer with a u64. And instead of looping at all,
we perform bitwise operations to write the desired number of bits.

Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), compression time
decreases from:

    13.62s to 10.9s on Serenity (cold)
    13.62s to 9.22s on Serenity (warm)
    2.93s to 2.32s on Linux

One caveat is that this requires explicitly flushing any leftover bits
when the caller is done with the stream. The byte buffer implementation
implicitly flushed its data every time the buffer was byte-aligned, as
doing so would always fill the byte. This is no longer the case. But for
now, this should be fine as the one user of this class, DEFLATE, already
has a "flush everything now that we're done" finalizer.
2023-04-02 10:54:37 +02:00
..
Brotli.cpp AK: Rename Stream::{read,write} to Stream::{read_some,write_some} 2023-03-13 15:16:20 +00:00
Brotli.h AK: Rename Stream::{read,write} to Stream::{read_some,write_some} 2023-03-13 15:16:20 +00:00
BrotliDictionary.cpp Everywhere: Add support for compilation under emscripten 2022-11-26 02:23:15 +03:30
BrotliDictionary.h LibCompress: Implement Brotli decompressor 2022-05-21 22:41:40 +02:00
BrotliDictionaryData.bin LibCompress: Implement Brotli decompressor 2022-05-21 22:41:40 +02:00
CMakeLists.txt LibCompress: Add support for XZ 2023-03-21 10:25:13 +01:00
Deflate.cpp AK: Increase LittleEndianOutputBitStream's buffer size and remove loops 2023-04-02 10:54:37 +02:00
Deflate.h LibCompress: Make CanonicalCode::from_bytes() return ErrorOr<> 2023-04-02 06:19:46 +02:00
DeflateTables.h LibCompress: Add missing header to DeflateTables.h 2021-10-06 23:52:40 +01:00
Gzip.cpp LibCompress: Add a utility to GZIP compress an entire file 2023-04-01 08:15:49 +02:00
Gzip.h LibCompress: Add a utility to GZIP compress an entire file 2023-04-01 08:15:49 +02:00
Lzma.cpp LibCompress: Use LZMA context from preexisting dictionary 2023-03-30 14:39:31 +02:00
Lzma.h LibCompress: Use the correct LZMA repetition offset in all cases 2023-03-30 14:39:31 +02:00
Lzma2.cpp LibCompress: Avoid overflowing the size of uncompressed LZMA2 chunks 2023-03-30 14:39:31 +02:00
Lzma2.h LibCompress: Add support for LZMA2 2023-03-21 10:25:13 +01:00
Xz.cpp LibCompress: Implement block size validation for XZ streams 2023-04-01 13:57:54 +02:00
Xz.h LibCompress: Implement block size validation for XZ streams 2023-04-01 13:57:54 +02:00
Zlib.cpp Everywhere: Remove unintentional partial stream reads and writes 2023-03-13 15:16:20 +00:00
Zlib.h AK: Rename Stream::{read,write} to Stream::{read_some,write_some} 2023-03-13 15:16:20 +00:00