enhance inline (#5610)
This commit is contained in:
@@ -10825,7 +10825,7 @@ Compressor.prototype.compress = function(node) {
|
||||
var begin;
|
||||
var in_order = [];
|
||||
var side_effects = false;
|
||||
value.walk(new TreeWalker(function(node, descend) {
|
||||
var tw = new TreeWalker(function(node, descend) {
|
||||
if (abort) return true;
|
||||
if (node instanceof AST_Binary && lazy_op[node.operator]
|
||||
|| node instanceof AST_Conditional) {
|
||||
@@ -10841,7 +10841,7 @@ Compressor.prototype.compress = function(node) {
|
||||
return;
|
||||
}
|
||||
if (def.init instanceof AST_LambdaDefinition) return abort = true;
|
||||
if (is_lhs(node, this.parent())) return abort = true;
|
||||
if (is_lhs(node, tw.parent())) return abort = true;
|
||||
var index = resolve_index(def);
|
||||
if (!(begin < index)) begin = index;
|
||||
if (!in_order) return;
|
||||
@@ -10852,12 +10852,21 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (side_effects) return;
|
||||
if (node instanceof AST_Assign && node.left instanceof AST_PropAccess) {
|
||||
node.left.expression.walk(tw);
|
||||
if (node.left instanceof AST_Sub) node.left.property.walk(tw);
|
||||
node.right.walk(tw);
|
||||
side_effects = true;
|
||||
return true;
|
||||
}
|
||||
if (node.has_side_effects(compressor)) {
|
||||
descend();
|
||||
side_effects = true;
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
});
|
||||
value.walk(tw);
|
||||
if (abort) return;
|
||||
var end = self.args.length;
|
||||
if (in_order && fn.argnames.length >= end) {
|
||||
|
||||
@@ -5512,6 +5512,40 @@ substitute_use_strict: {
|
||||
]
|
||||
}
|
||||
|
||||
substitute_assignment: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
properties: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, b, c) {
|
||||
a[b] = c;
|
||||
}
|
||||
var o = {};
|
||||
f(o, 42, null);
|
||||
f(o, "foo", "bar");
|
||||
for (var k in o)
|
||||
console.log(k, o[k]);
|
||||
}
|
||||
expect: {
|
||||
var o = {};
|
||||
o[42] = null;
|
||||
o.foo = "bar";
|
||||
for (var k in o)
|
||||
console.log(k, o[k]);
|
||||
}
|
||||
expect_stdout: [
|
||||
"42 null",
|
||||
"foo bar",
|
||||
]
|
||||
}
|
||||
|
||||
issue_3833_1: {
|
||||
options = {
|
||||
inline: 3,
|
||||
|
||||
Reference in New Issue
Block a user