diff --git a/lib/zlib/inflate.js b/lib/zlib/inflate.js index 83bbc7e..dbe74cd 100644 --- a/lib/zlib/inflate.js +++ b/lib/zlib/inflate.js @@ -156,17 +156,6 @@ function InflateState() { this.was = 0; /* initial length of match */ } -function InfTableOptions(type, lens, lens_index, codes, table, table_index, bits, work) { - this.type = type; - this.lens = lens; - this.lens_index = lens_index; - this.codes = codes; - this.table = table; - this.table_index = table_index; - this.bits = bits; - this.work = work; -} - function inflateResetKeep(strm) { var state; @@ -303,7 +292,7 @@ var lenfix, distfix; // We have no pointers in JS, so keep tables separate function fixedtables(state) { /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { - var sym, bits; + var sym; lenfix = new utils.Buf32(512); distfix = new utils.Buf32(32); @@ -315,15 +304,13 @@ function fixedtables(state) { while (sym < 280) { state.lens[sym++] = 7; } while (sym < 288) { state.lens[sym++] = 8; } - bits = 9; - inflate_table(new InfTableOptions(LENS, state.lens, 0, 288, lenfix, 0, bits, state.work)); + inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, {bits: 9}); /* distance table */ sym = 0; while (sym < 32) { state.lens[sym++] = 5; } - bits = 5; - inflate_table(new InfTableOptions(DISTS, state.lens, 0, 32, distfix, 0, bits, state.work)); + inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, {bits: 5}); /* do this just once */ virgin = false; @@ -941,8 +928,8 @@ function inflate(strm, flush) { utils.arraySet(state.lencode, state.codes, 0, state.codes.length, 0); state.lenbits = 7; - opts = new InfTableOptions(CODES, state.lens, 0, 19, state.lencode, 0, state.lenbits, state.work); - ret = inflate_table(opts); + opts = {bits: state.lenbits}; + ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); state.lenbits = opts.bits; if (ret) { @@ -1074,8 +1061,8 @@ function inflate(strm, flush) { utils.arraySet(state.lencode, state.codes, 0, state.codes.length, 0); state.lenbits = 9; - opts = new InfTableOptions(LENS, state.lens, 0, state.nlen,state.lencode,0, state.lenbits, state.work); - ret = inflate_table(opts); + opts = {bits: state.lenbits}; + ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); // state.next_index = opts.table_index; state.lenbits = opts.bits; // state.lencode = state.next; @@ -1089,8 +1076,8 @@ function inflate(strm, flush) { state.distbits = 6; //state.distcode.copy(state.codes); utils.arraySet(state.distcode, state.codes, 0, state.codes.length, 0); - opts = new InfTableOptions(DISTS, state.lens, state.nlen, state.ndist, state.distcode,0, state.distbits, state.work); - ret = inflate_table(opts); + opts = {bits: state.distbits}; + ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); // state.next_index = opts.table_index; state.distbits = opts.bits; // state.distcode = state.next; diff --git a/lib/zlib/inftrees.js b/lib/zlib/inftrees.js index f46bc21..1427cd8 100644 --- a/lib/zlib/inftrees.js +++ b/lib/zlib/inftrees.js @@ -34,14 +34,9 @@ var dext = [ /* Distance codes 0..29 extra */ 28, 28, 29, 29, 64, 64 ]; -module.exports = function inflate_table(opts) +module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { - var type = opts.type, - lens = opts.lens, - codes = opts.codes, - table = opts.table, - bits = opts.bits, - work = opts.work; + var bits = opts.bits; //here = opts.here; /* table entry for duplication */ var len = 0; /* a code's length in bits */ @@ -105,7 +100,7 @@ module.exports = function inflate_table(opts) count[len] = 0; } for (sym = 0; sym < codes; sym++) { - count[lens[opts.lens_index + sym]]++; + count[lens[lens_index + sym]]++; } /* bound code lengths, force root to be within code lengths */ @@ -120,13 +115,13 @@ module.exports = function inflate_table(opts) //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */ //table.bits[opts.table_index] = 1; //here.bits = (var char)1; //table.val[opts.table_index++] = 0; //here.val = (var short)0; - table[opts.table_index++] = (1 << 24) | (64 << 16) | 0; + table[table_index++] = (1 << 24) | (64 << 16) | 0; //table.op[opts.table_index] = 64; //table.bits[opts.table_index] = 1; //table.val[opts.table_index++] = 0; - table[opts.table_index++] = (1 << 24) | (64 << 16) | 0; + table[table_index++] = (1 << 24) | (64 << 16) | 0; opts.bits = 1; return 0; /* no symbols, but wait for decoding to report error */ @@ -159,8 +154,8 @@ module.exports = function inflate_table(opts) /* sort symbols by length, by symbol order within each length */ for (sym = 0; sym < codes; sym++) { - if (lens[opts.lens_index + sym] !== 0) { - work[offs[lens[opts.lens_index + sym]]++] = sym; + if (lens[lens_index + sym] !== 0) { + work[offs[lens[lens_index + sym]]++] = sym; } } @@ -218,7 +213,7 @@ module.exports = function inflate_table(opts) huff = 0; /* starting code */ sym = 0; /* starting code symbol */ len = min; /* starting code length */ - next = opts.table_index; /* current table to fill in */ + next = table_index; /* current table to fill in */ curr = root; /* current table index bits */ drop = 0; /* current bits to drop from code for index */ low = -1; /* trigger new sub-table when len > root */ @@ -275,7 +270,7 @@ module.exports = function inflate_table(opts) sym++; if (--(count[len]) === 0) { if (len === max) { break; } - len = lens[opts.lens_index + work[sym]]; + len = lens[lens_index + work[sym]]; } /* create new sub-table if needed */ @@ -310,7 +305,7 @@ module.exports = function inflate_table(opts) /*table.op[low] = curr; table.bits[low] = root; table.val[low] = next - opts.table_index;*/ - table[low] = (root << 24) | (curr << 16) | (next - opts.table_index); + table[low] = (root << 24) | (curr << 16) | (next - table_index); } } @@ -325,7 +320,7 @@ module.exports = function inflate_table(opts) } /* set return parameters */ - opts.table_index += used; + //opts.table_index += used; opts.bits = root; return 0; }; \ No newline at end of file