mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibCompress: Turn the DEFLATE implementation into a stream.
Previously, the implementation would produce one Vector<u8> which would contain the whole decompressed data. That can be a lot and even exhaust memory. With these changes it is still necessary to store the whole input data in one piece (I am working on this next,) but the output can be read block by block. (That's not optimal either because blocks can be arbitrarily large, but it's good for now.)
This commit is contained in:
parent
30abadcff9
commit
8bbb7e25e6
Notes:
sideshowbarker
2024-07-19 03:24:00 +09:00
Author: https://github.com/asynts
Commit: 8bbb7e25e6
Pull-request: https://github.com/SerenityOS/serenity/pull/3220
Reviewed-by: https://github.com/awesomekling
7 changed files with 187 additions and 74 deletions
|
@ -61,8 +61,7 @@ auto main(int argc, char** argv) -> int
|
|||
0xCB, 0x4A, 0x13, 0x00
|
||||
};
|
||||
|
||||
auto deflater = Compress::Deflate({ data_bytes, 4 * 7 });
|
||||
auto deflated = deflater.decompress();
|
||||
auto deflated = Compress::DeflateStream::decompress_all({ data_bytes, 4 * 7 });
|
||||
auto decompressed = String((const char*)deflated.data(), deflated.size());
|
||||
|
||||
if (decompressed.equals_ignoring_case("This is a simple text file :)")) {
|
||||
|
@ -80,7 +79,7 @@ auto main(int argc, char** argv) -> int
|
|||
0x78, 0x01, 0x01, 0x1D, 0x00, 0xE2, 0xFF, 0x54,
|
||||
0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61,
|
||||
0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20,
|
||||
0x74, 0x65, 0x78, 0x74, 0x20, 0x66, 0x69, 0x6C,
|
||||
0x74, 0x65, 0x78, 0x74, 0x20, 0x66, 0x69, 0x6C,
|
||||
0x65, 0x20, 0x3A, 0x29, 0x99, 0x5E, 0x09, 0xE8
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue