]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Small speedup to inflate [psumbera].
authorMark Adler <madler@alumni.caltech.edu>
Sun, 12 Feb 2017 07:21:41 +0000 (23:21 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 15 Jan 2019 11:12:50 +0000 (12:12 +0100)
Seeing a few percent speedup by using a pointer instead of an
assigned structure. This seems to help the compiler to optimize
better.

inffast.c

index 40e649a8b4fdf6d33f41f3a520a136bb8dffdb6d..34f0b8bd6120019120de6e5535ff09178485bd2c 100644 (file)
--- 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"));