fix sub-optimal optimisation
This commit is contained in:
parent
5037c186e3
commit
e9495bb82a
|
|
@ -722,10 +722,9 @@ merge(Compressor.prototype, {
|
||||||
var unwind = false;
|
var unwind = false;
|
||||||
var tt = new TreeTransformer(
|
var tt = new TreeTransformer(
|
||||||
function preorder(node) {
|
function preorder(node) {
|
||||||
if (unwind) return node;
|
if (unwind || node instanceof AST_Scope && node !== scope) return node;
|
||||||
var parent = tt.parent();
|
var parent = tt.parent();
|
||||||
if (node instanceof AST_Lambda
|
if (node instanceof AST_Try
|
||||||
|| node instanceof AST_Try
|
|
||||||
|| node instanceof AST_With
|
|| node instanceof AST_With
|
||||||
|| node instanceof AST_Case
|
|| node instanceof AST_Case
|
||||||
|| node instanceof AST_IterationStatement
|
|| node instanceof AST_IterationStatement
|
||||||
|
|
|
||||||
|
|
@ -1614,3 +1614,43 @@ reduce_vars_assign: {
|
||||||
}
|
}
|
||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iife_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var log = function(x) {
|
||||||
|
console.log(x);
|
||||||
|
}, foo = bar();
|
||||||
|
log(foo);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(x) {
|
||||||
|
console.log(x);
|
||||||
|
})(bar());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iife_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: false,
|
||||||
|
toplevel: true,
|
||||||
|
unused: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var foo = bar();
|
||||||
|
!function(x) {
|
||||||
|
console.log(x);
|
||||||
|
}(foo);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function(x) {
|
||||||
|
console.log(x);
|
||||||
|
}(bar());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user