From c3b8b3124c545fec7e8b09f446ee21635d410247 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 31 Mar 2023 09:04:53 -0400 Subject: [PATCH] LibCompress: Remove two needless heap allocations --- Userland/Libraries/LibCompress/Deflate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index 44d010b6f0..0246f18a42 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -362,8 +362,9 @@ void DeflateDecompressor::close() ErrorOr DeflateDecompressor::decompress_all(ReadonlyBytes bytes) { - auto memory_stream = TRY(try_make(bytes)); - auto deflate_stream = TRY(DeflateDecompressor::construct(make(move(memory_stream)))); + FixedMemoryStream memory_stream { bytes }; + LittleEndianInputBitStream bit_stream { MaybeOwned(memory_stream) }; + auto deflate_stream = TRY(DeflateDecompressor::construct(MaybeOwned(bit_stream))); AllocatingMemoryStream output_stream; auto buffer = TRY(ByteBuffer::create_uninitialized(4096));