in-place dead_code
This commit is contained in:
parent
bfbac53762
commit
c2174d06b2
|
|
@ -670,7 +670,7 @@ merge(Compressor.prototype, {
|
||||||
CHANGED = false;
|
CHANGED = false;
|
||||||
statements = eliminate_spurious_blocks(statements);
|
statements = eliminate_spurious_blocks(statements);
|
||||||
if (compressor.option("dead_code")) {
|
if (compressor.option("dead_code")) {
|
||||||
statements = eliminate_dead_code(statements, compressor);
|
eliminate_dead_code(statements, compressor);
|
||||||
}
|
}
|
||||||
if (compressor.option("if_return")) {
|
if (compressor.option("if_return")) {
|
||||||
statements = handle_if_return(statements, compressor);
|
statements = handle_if_return(statements, compressor);
|
||||||
|
|
@ -1062,35 +1062,37 @@ merge(Compressor.prototype, {
|
||||||
};
|
};
|
||||||
|
|
||||||
function eliminate_dead_code(statements, compressor) {
|
function eliminate_dead_code(statements, compressor) {
|
||||||
var has_quit = false;
|
var has_quit;
|
||||||
var orig = statements.length;
|
|
||||||
var self = compressor.self();
|
var self = compressor.self();
|
||||||
statements = statements.reduce(function(a, stat){
|
for (var i = 0, n = 0, len = statements.length; i < len; i++) {
|
||||||
if (has_quit) {
|
var stat = statements[i];
|
||||||
extract_declarations_from_unreachable_code(compressor, stat, a);
|
if (stat instanceof AST_LoopControl) {
|
||||||
} else {
|
var lct = compressor.loopcontrol_target(stat);
|
||||||
if (stat instanceof AST_LoopControl) {
|
if (stat instanceof AST_Break
|
||||||
var lct = compressor.loopcontrol_target(stat);
|
&& !(lct instanceof AST_IterationStatement)
|
||||||
if ((stat instanceof AST_Break
|
&& loop_body(lct) === self
|
||||||
&& !(lct instanceof AST_IterationStatement)
|
|| stat instanceof AST_Continue
|
||||||
&& loop_body(lct) === self) || (stat instanceof AST_Continue
|
&& loop_body(lct) === self) {
|
||||||
&& loop_body(lct) === self)) {
|
if (stat.label) {
|
||||||
if (stat.label) {
|
remove(stat.label.thedef.references, stat);
|
||||||
remove(stat.label.thedef.references, stat);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
a.push(stat);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a.push(stat);
|
statements[n++] = stat;
|
||||||
}
|
}
|
||||||
if (aborts(stat)) has_quit = true;
|
} else {
|
||||||
|
statements[n++] = stat;
|
||||||
}
|
}
|
||||||
return a;
|
if (aborts(stat)) {
|
||||||
}, []);
|
has_quit = statements.slice(i + 1);
|
||||||
CHANGED = statements.length != orig;
|
break;
|
||||||
return statements;
|
}
|
||||||
};
|
}
|
||||||
|
statements.length = n;
|
||||||
|
CHANGED = n != len;
|
||||||
|
if (has_quit) has_quit.forEach(function(stat) {
|
||||||
|
extract_declarations_from_unreachable_code(compressor, stat, statements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function sequencesize(statements, compressor) {
|
function sequencesize(statements, compressor) {
|
||||||
if (statements.length < 2) return;
|
if (statements.length < 2) return;
|
||||||
|
|
@ -1117,7 +1119,7 @@ merge(Compressor.prototype, {
|
||||||
statements.length = n;
|
statements.length = n;
|
||||||
sequencesize_2(statements, compressor);
|
sequencesize_2(statements, compressor);
|
||||||
CHANGED = statements.length != len;
|
CHANGED = statements.length != len;
|
||||||
};
|
}
|
||||||
|
|
||||||
function sequencesize_2(statements, compressor) {
|
function sequencesize_2(statements, compressor) {
|
||||||
function cons_seq(right) {
|
function cons_seq(right) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user