From: Mark Adler Date: Sun, 12 Feb 2017 07:21:41 +0000 (-0800) Subject: Small speedup to inflate [psumbera]. X-Git-Tag: 1.9.9-b1~562 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0da1279b83e1132b0e79ba3ab42c5c7daf0782da;p=thirdparty%2Fzlib-ng.git Small speedup to inflate [psumbera]. Seeing a few percent speedup by using a pointer instead of an assigned structure. This seems to help the compiler to optimize better. --- diff --git a/inffast.c b/inffast.c index 40e649a8..34f0b8bd 100644 --- a/inffast.c +++ b/inffast.c @@ -203,7 +203,7 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { code const *dcode; /* local strm->distcode */ unsigned lmask; /* mask for first level of length codes */ unsigned dmask; /* mask for first level of distance codes */ - code here; /* retrieved table entry */ + const code *here; /* retrieved table entry */ unsigned op; /* code bits, operation, extra bits, or */ /* window position, window bytes to copy */ unsigned len; /* match length, unused bytes */ @@ -243,17 +243,17 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { in += 6; bits += 48; } - here = lcode[hold & lmask]; + here = lcode + (hold & lmask); dolen: - DROPBITS(here.bits); - op = here.op; + DROPBITS(here->bits); + op = here->op; if (op == 0) { /* literal */ - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ? "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - *out++ = (unsigned char)(here.val); + "inflate: literal 0x%02x\n", here->val)); + *out++ = (unsigned char)(here->val); } else if (op & 16) { /* length base */ - len = here.val; + len = here->val; op &= 15; /* number of extra bits */ if (op) { if (bits < op) { @@ -270,12 +270,12 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { in += 6; bits += 48; } - here = dcode[hold & dmask]; + here = dcode + (hold & dmask); dodist: - DROPBITS(here.bits); - op = here.op; + DROPBITS(here->bits); + op = here->op; if (op & 16) { /* distance base */ - dist = here.val; + dist = here->val; op &= 15; /* number of extra bits */ if (bits < op) { hold |= load_64_bits(in, bits); @@ -422,7 +422,7 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { #endif } } else if ((op & 64) == 0) { /* 2nd level distance code */ - here = dcode[here.val + BITS(op)]; + here = dcode + here->val + BITS(op); goto dodist; } else { strm->msg = (char *)"invalid distance code"; @@ -430,7 +430,7 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { break; } } else if ((op & 64) == 0) { /* 2nd level length code */ - here = lcode[here.val + BITS(op)]; + here = lcode + here->val + BITS(op); goto dolen; } else if (op & 32) { /* end-of-block */ Tracevv((stderr, "inflate: end of block\n"));