inflate speed opts for old v8

This commit is contained in:
Vitaly Puzrin 2014-06-10 20:54:29 +04:00
parent d846c78df9
commit 0df06dbb67

View file

@ -191,19 +191,18 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
*/ */
/* set up for code type */ /* set up for code type */
switch (type) { // poor man optimization - use if-else instead of switch,
case CODES: // to avoid deopts in old v8
if (type === CODES) {
base = extra = work; /* dummy value--not used */ base = extra = work; /* dummy value--not used */
end = 19; end = 19;
break; } else if (type === LENS) {
case LENS:
base = lbase; base = lbase;
base_index -= 257; base_index -= 257;
extra = lext; extra = lext;
extra_index -= 257; extra_index -= 257;
end = 256; end = 256;
break; } else { /* DISTS */
default: /* DISTS */
base = dbase; base = dbase;
extra = dext; extra = dext;
end = -1; end = -1;
@ -323,4 +322,4 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
//opts.table_index += used; //opts.table_index += used;
opts.bits = root; opts.bits = root;
return 0; return 0;
}; };