diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2017-02-11 23:21:41 -0800 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2019-01-15 12:12:50 +0100 |
commit | 0da1279b83e1132b0e79ba3ab42c5c7daf0782da (patch) | |
tree | d186fd2e91e4ad45ed5f350049a89149a196b4f5 /inffast.c | |
parent | 9e74ca87d335481a621fe41cabf8e15b8cd1d77c (diff) |
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.
Diffstat (limited to 'inffast.c')
-rw-r--r-- | inffast.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -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")); |