aboutsummaryrefslogtreecommitdiff
path: root/inffast.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2017-02-11 23:21:41 -0800
committerMark Adler <madler@alumni.caltech.edu>2017-02-15 22:39:26 -0800
commit60a5ecc62b18d1e2391993b1fcfc10e100720642 (patch)
tree3759ea5b639381fb714b492f3762102bec62babd /inffast.c
parente1f1a3a1469c91b15ea1d31f1c2b92bdc27879fa (diff)
downloadzlib-60a5ecc62b18d1e2391993b1fcfc10e100720642.tar.gz
zlib-60a5ecc62b18d1e2391993b1fcfc10e100720642.tar.bz2
zlib-60a5ecc62b18d1e2391993b1fcfc10e100720642.zip
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.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/inffast.c b/inffast.c
index 0dbd1db..1fec7f3 100644
--- a/inffast.c
+++ b/inffast.c
@@ -70,7 +70,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
70 code const FAR *dcode; /* local strm->distcode */ 70 code const FAR *dcode; /* local strm->distcode */
71 unsigned lmask; /* mask for first level of length codes */ 71 unsigned lmask; /* mask for first level of length codes */
72 unsigned dmask; /* mask for first level of distance codes */ 72 unsigned dmask; /* mask for first level of distance codes */
73 code here; /* retrieved table entry */ 73 code const *here; /* retrieved table entry */
74 unsigned op; /* code bits, operation, extra bits, or */ 74 unsigned op; /* code bits, operation, extra bits, or */
75 /* window position, window bytes to copy */ 75 /* window position, window bytes to copy */
76 unsigned len; /* match length, unused bytes */ 76 unsigned len; /* match length, unused bytes */
@@ -107,20 +107,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
107 hold += (unsigned long)(*in++) << bits; 107 hold += (unsigned long)(*in++) << bits;
108 bits += 8; 108 bits += 8;
109 } 109 }
110 here = lcode[hold & lmask]; 110 here = lcode + (hold & lmask);
111 dolen: 111 dolen:
112 op = (unsigned)(here.bits); 112 op = (unsigned)(here->bits);
113 hold >>= op; 113 hold >>= op;
114 bits -= op; 114 bits -= op;
115 op = (unsigned)(here.op); 115 op = (unsigned)(here->op);
116 if (op == 0) { /* literal */ 116 if (op == 0) { /* literal */
117 Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? 117 Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
118 "inflate: literal '%c'\n" : 118 "inflate: literal '%c'\n" :
119 "inflate: literal 0x%02x\n", here.val)); 119 "inflate: literal 0x%02x\n", here->val));
120 *out++ = (unsigned char)(here.val); 120 *out++ = (unsigned char)(here->val);
121 } 121 }
122 else if (op & 16) { /* length base */ 122 else if (op & 16) { /* length base */
123 len = (unsigned)(here.val); 123 len = (unsigned)(here->val);
124 op &= 15; /* number of extra bits */ 124 op &= 15; /* number of extra bits */
125 if (op) { 125 if (op) {
126 if (bits < op) { 126 if (bits < op) {
@@ -138,14 +138,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
138 hold += (unsigned long)(*in++) << bits; 138 hold += (unsigned long)(*in++) << bits;
139 bits += 8; 139 bits += 8;
140 } 140 }
141 here = dcode[hold & dmask]; 141 here = dcode + (hold & dmask);
142 dodist: 142 dodist:
143 op = (unsigned)(here.bits); 143 op = (unsigned)(here->bits);
144 hold >>= op; 144 hold >>= op;
145 bits -= op; 145 bits -= op;
146 op = (unsigned)(here.op); 146 op = (unsigned)(here->op);
147 if (op & 16) { /* distance base */ 147 if (op & 16) { /* distance base */
148 dist = (unsigned)(here.val); 148 dist = (unsigned)(here->val);
149 op &= 15; /* number of extra bits */ 149 op &= 15; /* number of extra bits */
150 if (bits < op) { 150 if (bits < op) {
151 hold += (unsigned long)(*in++) << bits; 151 hold += (unsigned long)(*in++) << bits;
@@ -264,7 +264,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
264 } 264 }
265 } 265 }
266 else if ((op & 64) == 0) { /* 2nd level distance code */ 266 else if ((op & 64) == 0) { /* 2nd level distance code */
267 here = dcode[here.val + (hold & ((1U << op) - 1))]; 267 here = dcode + here->val + (hold & ((1U << op) - 1));
268 goto dodist; 268 goto dodist;
269 } 269 }
270 else { 270 else {
@@ -274,7 +274,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
274 } 274 }
275 } 275 }
276 else if ((op & 64) == 0) { /* 2nd level length code */ 276 else if ((op & 64) == 0) { /* 2nd level length code */
277 here = lcode[here.val + (hold & ((1U << op) - 1))]; 277 here = lcode + here->val + (hold & ((1U << op) - 1));
278 goto dolen; 278 goto dolen;
279 } 279 }
280 else if (op & 32) { /* end-of-block */ 280 else if (op & 32) { /* end-of-block */