From aeb8224ec8320fbad27df35aa7170d82977d32e0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 24 Mar 2023 13:48:17 +0100 Subject: [PATCH] LibCompress: Speed up deflate decompression by ~11% ...simply by using LittleEndianInputBitStream::read_bit() instead of read_bits(1). This puts us on the fast path for single-bit reads. There's still lots of money on the table for bigger optimizations to claim here, just picking an embarrassingly low-hanging fruit. :^) --- Userland/Libraries/LibCompress/Deflate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index 8660163951..a5ac0d1c1d 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -104,7 +104,7 @@ ErrorOr CanonicalCode::read_symbol(LittleEndianInputBitStream& stream) cons u32 code_bits = 1; for (;;) { - code_bits = code_bits << 1 | TRY(stream.read_bits(1)); + code_bits = code_bits << 1 | TRY(stream.read_bit()); if (code_bits >= (1 << 16)) return Error::from_string_literal("Symbol exceeds maximum symbol number");