mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-20 11:53:49 +01:00
inflate_fast() now works with packed tables directly
This commit is contained in:
parent
f09d27bc1e
commit
a6ec0c7820
1 changed files with 14 additions and 14 deletions
|
@ -72,7 +72,7 @@ module.exports = function inflate_fast(strm, start) {
|
||||||
|
|
||||||
/* copy state to local variables */
|
/* copy state to local variables */
|
||||||
state = strm.state;
|
state = strm.state;
|
||||||
here = state.here;
|
//here = state.here;
|
||||||
_in = strm.next_in_index;
|
_in = strm.next_in_index;
|
||||||
input = strm.next_in;
|
input = strm.next_in;
|
||||||
last = _in + (strm.avail_in - 5);
|
last = _in + (strm.avail_in - 5);
|
||||||
|
@ -89,8 +89,8 @@ module.exports = function inflate_fast(strm, start) {
|
||||||
window = state.window;
|
window = state.window;
|
||||||
hold = state.hold;
|
hold = state.hold;
|
||||||
bits = state.bits;
|
bits = state.bits;
|
||||||
lcode = state.lencode;
|
lcode = state.lencode.data;
|
||||||
dcode = state.distcode;
|
dcode = state.distcode.data;
|
||||||
lmask = (1 << state.lenbits) - 1;
|
lmask = (1 << state.lenbits) - 1;
|
||||||
dmask = (1 << state.distbits) - 1;
|
dmask = (1 << state.distbits) - 1;
|
||||||
|
|
||||||
|
@ -107,22 +107,22 @@ module.exports = function inflate_fast(strm, start) {
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcode.fill(hold & lmask, here);
|
here = lcode[hold & lmask];
|
||||||
|
|
||||||
dolen:
|
dolen:
|
||||||
for (;;) { // Goto emulation
|
for (;;) { // Goto emulation
|
||||||
op = here.bits;
|
op = here >>> 24/*here.bits*/;
|
||||||
hold >>>= op;
|
hold >>>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = here.op;
|
op = (here >>> 16) & 0xff/*here.op*/;
|
||||||
if (op === 0) { /* literal */
|
if (op === 0) { /* literal */
|
||||||
//Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
//Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
// "inflate: literal '%c'\n" :
|
// "inflate: literal '%c'\n" :
|
||||||
// "inflate: literal 0x%02x\n", here.val));
|
// "inflate: literal 0x%02x\n", here.val));
|
||||||
output[_out++] = here.val;
|
output[_out++] = here & 0xffff/*here.val*/;
|
||||||
}
|
}
|
||||||
else if (op & 16) { /* length base */
|
else if (op & 16) { /* length base */
|
||||||
len = here.val;
|
len = here & 0xffff/*here.val*/;
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (op) {
|
if (op) {
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
|
@ -140,17 +140,17 @@ module.exports = function inflate_fast(strm, start) {
|
||||||
hold += input[_in++] << bits;
|
hold += input[_in++] << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
dcode.fill(hold & dmask, here);
|
here = dcode[hold & dmask];
|
||||||
|
|
||||||
dodist:
|
dodist:
|
||||||
for (;;) { // goto emulation
|
for (;;) { // goto emulation
|
||||||
op = here.bits;
|
op = here >>> 24/*here.bits*/;
|
||||||
hold >>>= op;
|
hold >>>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = here.op;
|
op = (here >>> 16) & 0xff/*here.op*/;
|
||||||
|
|
||||||
if (op & 16) { /* distance base */
|
if (op & 16) { /* distance base */
|
||||||
dist = here.val;
|
dist = here & 0xffff/*here.val*/;
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += input[_in++] << bits;
|
hold += input[_in++] << bits;
|
||||||
|
@ -274,7 +274,7 @@ module.exports = function inflate_fast(strm, start) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) === 0) { /* 2nd level distance code */
|
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;
|
continue dodist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -287,7 +287,7 @@ module.exports = function inflate_fast(strm, start) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) === 0) { /* 2nd level length code */
|
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;
|
continue dolen;
|
||||||
}
|
}
|
||||||
else if (op & 32) { /* end-of-block */
|
else if (op & 32) { /* end-of-block */
|
||||||
|
|
Loading…
Add table
Reference in a new issue