summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-24 13:48:17 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-24 17:08:35 +0100
commitaeb8224ec8320fbad27df35aa7170d82977d32e0 (patch)
treec4998eba46c3c4215fcf93c735fa4df9a9c7dadf
parentea9707ec2962bab55dc5ee783a3d7bb2c9fa638b (diff)
downloadserenity-aeb8224ec8320fbad27df35aa7170d82977d32e0.zip
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. :^)
-rw-r--r--Userland/Libraries/LibCompress/Deflate.cpp2
1 files changed, 1 insertions, 1 deletions
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<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");