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. :^)
This commit is contained in:
Andreas Kling 2023-03-24 13:48:17 +01:00
parent ea9707ec29
commit aeb8224ec8

View file

@ -104,7 +104,7 @@ ErrorOr<u32> 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");