inffast.c (7648bc9fee8dec6cb3c4941e0165a930fbe8dcb0) | inffast.c (cd8822075a38d0734e74b1735e4b5dbef9789170) |
---|---|
1/* inffast.c -- fast decoding 2 * Copyright (C) 1995-2017 Mark Adler 3 * For conditions of distribution and use, see copyright notice in zlib.h 4 */ 5 6#include "zutil.h" 7#include "inftrees.h" 8#include "inflate.h" --- 56 unchanged lines hidden (view full) --- 65 unsigned wnext; /* window write index */ 66 unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ 67 unsigned long hold; /* local strm->hold */ 68 unsigned bits; /* local strm->bits */ 69 code const FAR *lcode; /* local strm->lencode */ 70 code const FAR *dcode; /* local strm->distcode */ 71 unsigned lmask; /* mask for first level of length codes */ 72 unsigned dmask; /* mask for first level of distance codes */ | 1/* inffast.c -- fast decoding 2 * Copyright (C) 1995-2017 Mark Adler 3 * For conditions of distribution and use, see copyright notice in zlib.h 4 */ 5 6#include "zutil.h" 7#include "inftrees.h" 8#include "inflate.h" --- 56 unchanged lines hidden (view full) --- 65 unsigned wnext; /* window write index */ 66 unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ 67 unsigned long hold; /* local strm->hold */ 68 unsigned bits; /* local strm->bits */ 69 code const FAR *lcode; /* local strm->lencode */ 70 code const FAR *dcode; /* local strm->distcode */ 71 unsigned lmask; /* mask for first level of length 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 */ 75 /* window position, window bytes to copy */ 76 unsigned len; /* match length, unused bytes */ 77 unsigned dist; /* match distance */ 78 unsigned char FAR *from; /* where to copy match from */ 79 80 /* copy state to local variables */ 81 state = (struct inflate_state FAR *)strm->state; --- 20 unchanged lines hidden (view full) --- 102 input data or output space */ 103 do { 104 if (bits < 15) { 105 hold += (unsigned long)(*in++) << bits; 106 bits += 8; 107 hold += (unsigned long)(*in++) << bits; 108 bits += 8; 109 } | 74 unsigned op; /* code bits, operation, extra bits, or */ 75 /* window position, window bytes to copy */ 76 unsigned len; /* match length, unused bytes */ 77 unsigned dist; /* match distance */ 78 unsigned char FAR *from; /* where to copy match from */ 79 80 /* copy state to local variables */ 81 state = (struct inflate_state FAR *)strm->state; --- 20 unchanged lines hidden (view full) --- 102 input data or output space */ 103 do { 104 if (bits < 15) { 105 hold += (unsigned long)(*in++) << bits; 106 bits += 8; 107 hold += (unsigned long)(*in++) << bits; 108 bits += 8; 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; 114 bits -= op; | 113 hold >>= 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)); 120 *out++ = (unsigned char)(here.val); | 119 "inflate: literal 0x%02x\n", here->val)); 120 *out++ = (unsigned char)(here->val); |
121 } 122 else if (op & 16) { /* length base */ | 121 } 122 else if (op & 16) { /* length base */ |
123 len = (unsigned)(here.val); | 123 len = (unsigned)(here->val); |
124 op &= 15; /* number of extra bits */ 125 if (op) { 126 if (bits < op) { 127 hold += (unsigned long)(*in++) << bits; 128 bits += 8; 129 } 130 len += (unsigned)hold & ((1U << op) - 1); 131 hold >>= op; 132 bits -= op; 133 } 134 Tracevv((stderr, "inflate: length %u\n", len)); 135 if (bits < 15) { 136 hold += (unsigned long)(*in++) << bits; 137 bits += 8; 138 hold += (unsigned long)(*in++) << bits; 139 bits += 8; 140 } | 124 op &= 15; /* number of extra bits */ 125 if (op) { 126 if (bits < op) { 127 hold += (unsigned long)(*in++) << bits; 128 bits += 8; 129 } 130 len += (unsigned)hold & ((1U << op) - 1); 131 hold >>= op; 132 bits -= op; 133 } 134 Tracevv((stderr, "inflate: length %u\n", len)); 135 if (bits < 15) { 136 hold += (unsigned long)(*in++) << bits; 137 bits += 8; 138 hold += (unsigned long)(*in++) << bits; 139 bits += 8; 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; 145 bits -= op; | 144 hold >>= 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 */ 150 if (bits < op) { 151 hold += (unsigned long)(*in++) << bits; 152 bits += 8; 153 if (bits < op) { 154 hold += (unsigned long)(*in++) << bits; 155 bits += 8; 156 } --- 102 unchanged lines hidden (view full) --- 259 if (len) { 260 *out++ = *from++; 261 if (len > 1) 262 *out++ = *from++; 263 } 264 } 265 } 266 else if ((op & 64) == 0) { /* 2nd level distance code */ | 149 op &= 15; /* number of extra bits */ 150 if (bits < op) { 151 hold += (unsigned long)(*in++) << bits; 152 bits += 8; 153 if (bits < op) { 154 hold += (unsigned long)(*in++) << bits; 155 bits += 8; 156 } --- 102 unchanged lines hidden (view full) --- 259 if (len) { 260 *out++ = *from++; 261 if (len > 1) 262 *out++ = *from++; 263 } 264 } 265 } 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; 269 } 270 else { 271 strm->msg = (char *)"invalid distance code"; 272 state->mode = BAD; 273 break; 274 } 275 } 276 else if ((op & 64) == 0) { /* 2nd level length code */ | 268 goto dodist; 269 } 270 else { 271 strm->msg = (char *)"invalid distance code"; 272 state->mode = BAD; 273 break; 274 } 275 } 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; 279 } 280 else if (op & 32) { /* end-of-block */ 281 Tracevv((stderr, "inflate: end of block\n")); 282 state->mode = TYPE; 283 break; 284 } 285 else { --- 38 unchanged lines hidden --- | 278 goto dolen; 279 } 280 else if (op & 32) { /* end-of-block */ 281 Tracevv((stderr, "inflate: end of block\n")); 282 state->mode = TYPE; 283 break; 284 } 285 else { --- 38 unchanged lines hidden --- |