diff options
author | Josh Triplett <josh@joshtriplett.org> | 2020-08-13 20:59:17 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-08-16 17:35:53 +0200 |
commit | bcb1d58c05a06c61dac50318bb124413619fb436 (patch) | |
tree | 5361962f2fbac3a74a769ee9c21c93d30a195379 /inffast.c | |
parent | dac5ec72a22f77dea6594f1da52fbe805462599b (diff) |
Optimize inflate_fast for a 0.8% speedup
When inflate_fast checks for extra length bits, it first checks if the
number of extra length bits (in op) is non-zero. However, if the number
of extra length bits is 0, the `bits < op` check will be false, BITS(op)
will be 0, and DROPBITS(op) will do nothing. So, drop the conditional,
for a speedup of about 0.8%.
This makes the handling of extra length bits match the handling of extra
dist bits, which already lacks the extra conditional.
Diffstat (limited to 'inffast.c')
-rw-r--r-- | inffast.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -171,15 +171,13 @@ void ZLIB_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) } else if (op & 16) { /* length base */ len = here->val; op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold |= load_64_bits(in, bits); - in += 6; - bits += 48; - } - len += BITS(op); - DROPBITS(op); + if (bits < op) { + hold |= load_64_bits(in, bits); + in += 6; + bits += 48; } + len += BITS(op); + DROPBITS(op); Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { hold |= load_64_bits(in, bits); |