Skip to content

Commit 0eb0307

Browse files
committed
Remove offset pointer optimization in inftrees.c
1 parent 138efa6 commit 0eb0307

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

builtins/zlib/inftrees.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define MAXBITS 15
1010

1111
const char inflate_copyright[] =
12-
" inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
12+
" inflate 1.2.8.1 Copyright 1995-2013 Mark Adler ";
1313
/*
1414
If you use the zlib library in a product, an acknowledgment is welcome
1515
in the documentation of your product. If for some reason you cannot
@@ -48,15 +48,15 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne
4848
code FAR *next; /* next available space in table */
4949
const unsigned short FAR *base; /* base value table to use */
5050
const unsigned short FAR *extra; /* extra bits table to use */
51-
int end; /* use base and extra for symbol > end */
51+
unsigned match; /* use base and extra for symbol >= match */
5252
unsigned short count[MAXBITS+1]; /* number of codes of each length */
5353
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
5454
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
5555
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
5656
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
5757
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
5858
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
59-
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
59+
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 198};
6060
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
6161
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
6262
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -175,19 +175,17 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne
175175
switch (type) {
176176
case CODES:
177177
base = extra = work; /* dummy value--not used */
178-
end = 19;
178+
match = 20;
179179
break;
180180
case LENS:
181181
base = lbase;
182-
base -= 257;
183182
extra = lext;
184-
extra -= 257;
185-
end = 256;
183+
match = 257;
186184
break;
187185
default: /* DISTS */
188186
base = dbase;
189187
extra = dext;
190-
end = -1;
188+
match = 0;
191189
}
192190

193191
/* initialize state for loop */
@@ -210,13 +208,13 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne
210208
for (;;) {
211209
/* create table entry */
212210
here.bits = (unsigned char)(len - drop);
213-
if ((int)(work[sym]) < end) {
211+
if (work[sym] + 1 < match) {
214212
here.op = (unsigned char)0;
215213
here.val = work[sym];
216214
}
217-
else if ((int)(work[sym]) > end) {
218-
here.op = (unsigned char)(extra[work[sym]]);
219-
here.val = base[work[sym]];
215+
else if (work[sym] >= match) {
216+
here.op = (unsigned char)(extra[work[sym] - match]);
217+
here.val = base[work[sym] - match];
220218
}
221219
else {
222220
here.op = (unsigned char)(32 + 64); /* end of block */

0 commit comments

Comments
 (0)