mirror of
https://bitbucket.org/anticensority/antizapret-pac-generator-light.git
synced 2024-11-22 05:06:04 +03:00
Streamable LZP decompression, fit into Firefox 52 heap size
This commit is contained in:
parent
4c88eb1264
commit
a507f39d67
@ -60,10 +60,14 @@ function patternreplace(s, lzpmask) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
// LZP as in PPP, different hash func
|
// LZP as in PPP, different hash func
|
||||||
function unlzp(d, m) {
|
var TABLE_LEN_BITS = 18;
|
||||||
|
var HASH_MASK = (1 << TABLE_LEN_BITS) - 1;
|
||||||
|
var table = Array(1 << TABLE_LEN_BITS);
|
||||||
|
var hash = 0;
|
||||||
|
function unlzp(d, m, lim) {
|
||||||
var TABLE_LEN_BITS = 18;
|
var TABLE_LEN_BITS = 18;
|
||||||
var HASH_MASK = (1 << TABLE_LEN_BITS) - 1;
|
var HASH_MASK = (1 << TABLE_LEN_BITS) - 1;
|
||||||
var hash = 0, mask = 0, maskpos = 0, dpos = 0, table = Array(1 << TABLE_LEN_BITS), out = Array(8), outpos = 0, outfinal = '';
|
var mask = 0, maskpos = 0, dpos = 0, out = Array(8), outpos = 0, outfinal = '';
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
mask = m[maskpos++];
|
mask = m[maskpos++];
|
||||||
@ -86,10 +90,11 @@ function unlzp(d, m) {
|
|||||||
}
|
}
|
||||||
if (outpos == 8)
|
if (outpos == 8)
|
||||||
outfinal += out.join('');
|
outfinal += out.join('');
|
||||||
|
if (outfinal.length >= lim) break;
|
||||||
}
|
}
|
||||||
if (outpos < 8)
|
if (outpos < 8)
|
||||||
outfinal += out.slice(0, outpos).join('');
|
outfinal += out.slice(0, outpos).join('');
|
||||||
return outfinal;
|
return [outfinal, dpos, maskpos];
|
||||||
}
|
}
|
||||||
|
|
||||||
function a2b(a) {
|
function a2b(a) {
|
||||||
@ -128,19 +133,37 @@ echo " if (domains.length < 10) return \"DIRECT\"; // list is broken
|
|||||||
special[i][1] = nmfc(special[i][1]);
|
special[i][1] = nmfc(special[i][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mask_lzp = patternreplace(mask_lzp, true);
|
mask_lzp = a2b(patternreplace(mask_lzp, true));
|
||||||
mask_lzp = a2b(mask_lzp);
|
|
||||||
domains_lzp = unlzp(domains_lzp, mask_lzp);
|
|
||||||
mask_lzp = 0;
|
|
||||||
|
|
||||||
|
var leftover = '';
|
||||||
for (dmn in domains) {
|
for (dmn in domains) {
|
||||||
for (dcnt in domains[dmn]) {
|
for (dcnt in domains[dmn]) {
|
||||||
dmnl = domains[dmn][dcnt];
|
dmnl = domains[dmn][dcnt];
|
||||||
domains[dmn][dcnt] = domains_lzp.slice(0, dmnl);
|
if (leftover.length < dmnl) {
|
||||||
domains_lzp = domains_lzp.slice(dmnl);
|
var reqd = (dmnl<=8192 ? 8192 : dmnl);
|
||||||
|
var u = unlzp(domains_lzp, mask_lzp, reqd);
|
||||||
|
domains_lzp = domains_lzp.slice(u[1]);
|
||||||
|
mask_lzp = mask_lzp.slice(u[2]);
|
||||||
|
leftover += u[0]
|
||||||
|
u = 0
|
||||||
|
//console.log('Requested ' + reqd);
|
||||||
|
//if (reqd > leftover.length) {alert('requested ' + reqd + ' got ' + leftover.length);}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftover.length >= dmnl) {
|
||||||
|
domains[dmn][dcnt] = leftover.slice(0, dmnl);
|
||||||
|
leftover = leftover.slice(dmnl);
|
||||||
|
if (domains[dmn][dcnt].length != dmnl) alert('ERR 1!');
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
alert('ERR 3');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (domains[dmn][dcnt].length != dmnl) alert('ERR 2');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table = 0;
|
||||||
az_initialized = 1;
|
az_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user