diff --git a/lib/zlib/inftrees.js b/lib/zlib/inftrees.js index b5b29d3..eee389e 100644 --- a/lib/zlib/inftrees.js +++ b/lib/zlib/inftrees.js @@ -70,13 +70,11 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work, let mask; /* mask for low root bits */ let next; /* next available space in table */ let base = null; /* base value table to use */ - let base_index = 0; // let shoextra; /* extra bits table to use */ - let end; /* use base and extra for symbol > end */ + let match; /* use base and extra for symbol >= match */ const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */ const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */ let extra = null; - let extra_index = 0; let here_bits, here_op, here_val; @@ -211,19 +209,17 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work, // to avoid deopts in old v8 if (type === CODES) { base = extra = work; /* dummy value--not used */ - end = 19; + match = 20; } else if (type === LENS) { base = lbase; - base_index -= 257; extra = lext; - extra_index -= 257; - end = 256; + match = 257; } else { /* DISTS */ base = dbase; extra = dext; - end = -1; + match = 0; } /* initialize opts for loop */ @@ -247,13 +243,13 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work, for (;;) { /* create table entry */ here_bits = len - drop; - if (work[sym] < end) { + if (work[sym] + 1 < match) { here_op = 0; here_val = work[sym]; } - else if (work[sym] > end) { - here_op = extra[extra_index + work[sym]]; - here_val = base[base_index + work[sym]]; + else if (work[sym] >= match) { + here_op = extra[work[sym] - match]; + here_val = base[work[sym] - match]; } else { here_op = 32 + 64; /* end of block */