From 9f238793e0e039ff6eb18c91acd0c3c7cde2b638 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 30 Mar 2023 14:01:07 -0400 Subject: [PATCH] gunzip+LibCompress: Increase buffer sizes used by Deflate and gunzip Co-authored-by: Andreas Kling --- Userland/Libraries/LibCompress/Deflate.cpp | 2 +- Userland/Libraries/LibCompress/Deflate.h | 4 ++-- Userland/Utilities/gunzip.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index bfdeb991a4..04d26eba02 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -436,7 +436,7 @@ ErrorOr DeflateDecompressor::decode_codes(CanonicalCode& literal_code, Opt // Next we extract the code lengths of the code that was used to encode the block. - Vector code_lengths; + Vector code_lengths; while (code_lengths.size() < literal_code_count + distance_code_count) { auto symbol = TRY(code_length_code.read_symbol(*m_input_stream)); diff --git a/Userland/Libraries/LibCompress/Deflate.h b/Userland/Libraries/LibCompress/Deflate.h index 1ca761ad40..53acf24603 100644 --- a/Userland/Libraries/LibCompress/Deflate.h +++ b/Userland/Libraries/LibCompress/Deflate.h @@ -38,8 +38,8 @@ private: }; // Decompression - indexed by code - Vector m_symbol_codes; - Vector m_symbol_values; + Vector m_symbol_codes; + Vector m_symbol_values; Array m_prefix_table {}; size_t m_max_prefixed_code_length { 0 }; diff --git a/Userland/Utilities/gunzip.cpp b/Userland/Utilities/gunzip.cpp index 217550834a..d7601c4561 100644 --- a/Userland/Utilities/gunzip.cpp +++ b/Userland/Utilities/gunzip.cpp @@ -15,7 +15,7 @@ static ErrorOr decompress_file(NonnullOwnPtr input_stream, Stream& { auto gzip_stream = Compress::GzipDecompressor { move(input_stream) }; - auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); + auto buffer = TRY(ByteBuffer::create_uninitialized(256 * KiB)); while (!gzip_stream.is_eof()) { auto span = TRY(gzip_stream.read_some(buffer)); TRY(output_stream.write_until_depleted(span)); @@ -52,7 +52,7 @@ ErrorOr serenity_main(Main::Arguments args) } auto input_file = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read)); - auto buffered_input_file = TRY(Core::BufferedFile::create(move(input_file))); + auto buffered_input_file = TRY(Core::BufferedFile::create(move(input_file), 256 * KiB)); auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));