inflate_fast() now works with packed tables directly

master
Vitaly Puzrin 2014-03-13 00:12:05 +04:00
rodzic f09d27bc1e
commit a6ec0c7820
1 zmienionych plików z 14 dodań i 14 usunięć

Wyświetl plik

@ -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 */