From a6ec0c78200aae841b7de331cae90f9e77fb7516 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Thu, 13 Mar 2014 00:12:05 +0400 Subject: [PATCH] inflate_fast() now works with packed tables directly --- lib/zlib/inffast.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/zlib/inffast.js b/lib/zlib/inffast.js index 770fc8d..9fb7b3c 100644 --- a/lib/zlib/inffast.js +++ b/lib/zlib/inffast.js @@ -72,7 +72,7 @@ module.exports = function inflate_fast(strm, start) { /* copy state to local variables */ state = strm.state; - here = state.here; + //here = state.here; _in = strm.next_in_index; input = strm.next_in; last = _in + (strm.avail_in - 5); @@ -89,8 +89,8 @@ module.exports = function inflate_fast(strm, start) { window = state.window; hold = state.hold; bits = state.bits; - lcode = state.lencode; - dcode = state.distcode; + lcode = state.lencode.data; + dcode = state.distcode.data; lmask = (1 << state.lenbits) - 1; dmask = (1 << state.distbits) - 1; @@ -107,22 +107,22 @@ module.exports = function inflate_fast(strm, start) { bits += 8; } - lcode.fill(hold & lmask, here); + here = lcode[hold & lmask]; dolen: for (;;) { // Goto emulation - op = here.bits; + op = here >>> 24/*here.bits*/; hold >>>= op; bits -= op; - op = here.op; + op = (here >>> 16) & 0xff/*here.op*/; if (op === 0) { /* literal */ //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? // "inflate: literal '%c'\n" : // "inflate: literal 0x%02x\n", here.val)); - output[_out++] = here.val; + output[_out++] = here & 0xffff/*here.val*/; } else if (op & 16) { /* length base */ - len = here.val; + len = here & 0xffff/*here.val*/; op &= 15; /* number of extra bits */ if (op) { if (bits < op) { @@ -140,17 +140,17 @@ module.exports = function inflate_fast(strm, start) { hold += input[_in++] << bits; bits += 8; } - dcode.fill(hold & dmask, here); + here = dcode[hold & dmask]; dodist: for (;;) { // goto emulation - op = here.bits; + op = here >>> 24/*here.bits*/; hold >>>= op; bits -= op; - op = here.op; + op = (here >>> 16) & 0xff/*here.op*/; if (op & 16) { /* distance base */ - dist = here.val; + dist = here & 0xffff/*here.val*/; op &= 15; /* number of extra bits */ if (bits < op) { hold += input[_in++] << bits; @@ -274,7 +274,7 @@ module.exports = function inflate_fast(strm, start) { } } else if ((op & 64) === 0) { /* 2nd level distance code */ - dcode.fill(here.val + (hold & ((1 << op) - 1)), here); + here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; continue dodist; } else { @@ -287,7 +287,7 @@ module.exports = function inflate_fast(strm, start) { } } else if ((op & 64) === 0) { /* 2nd level length code */ - lcode.fill(here.val + (hold & ((1 << op) - 1)), here); + here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; continue dolen; } else if (op & 32) { /* end-of-block */