enhance inline (#5610)

This commit is contained in:
Alex Lam S.L
2022-08-09 15:54:29 +01:00
committed by GitHub
parent c32fe26b8d
commit 5a4cd09938
2 changed files with 46 additions and 3 deletions

View File

@@ -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) {