@@ -1869,22 +1869,26 @@ Compressor.prototype.compress = function(node) {
|
||||
if (handle_if_return(statements, compressor)) changed = 3;
|
||||
if (!changed && last_changed == 3) break;
|
||||
}
|
||||
if (compressor.option("inline") >= 4) {
|
||||
if (inline_iife(statements, compressor)) changed = 4;
|
||||
if (compressor.option("awaits") && compressor.option("side_effects")) {
|
||||
if (trim_awaits(statements, compressor)) changed = 4;
|
||||
if (!changed && last_changed == 4) break;
|
||||
}
|
||||
if (compressor.sequences_limit > 0) {
|
||||
if (sequencesize(statements, compressor)) changed = 5;
|
||||
if (compressor.option("inline") >= 4) {
|
||||
if (inline_iife(statements, compressor)) changed = 5;
|
||||
if (!changed && last_changed == 5) break;
|
||||
if (sequencesize_2(statements, compressor)) changed = 6;
|
||||
if (!changed && last_changed == 6) break;
|
||||
}
|
||||
if (compressor.option("join_vars")) {
|
||||
if (join_consecutive_vars(statements)) changed = 7;
|
||||
if (compressor.sequences_limit > 0) {
|
||||
if (sequencesize(statements, compressor)) changed = 6;
|
||||
if (!changed && last_changed == 6) break;
|
||||
if (sequencesize_2(statements, compressor)) changed = 7;
|
||||
if (!changed && last_changed == 7) break;
|
||||
}
|
||||
if (compressor.option("join_vars")) {
|
||||
if (join_consecutive_vars(statements)) changed = 8;
|
||||
if (!changed && last_changed == 8) break;
|
||||
}
|
||||
if (compressor.option("collapse_vars")) {
|
||||
if (collapse(statements, compressor)) changed = 8;
|
||||
if (collapse(statements, compressor)) changed = 9;
|
||||
}
|
||||
} while (changed && max_iter-- > 0);
|
||||
return statements;
|
||||
@@ -3524,6 +3528,27 @@ Compressor.prototype.compress = function(node) {
|
||||
return statements.length != len;
|
||||
}
|
||||
|
||||
function trim_awaits(statements, compressor) {
|
||||
if (!in_lambda || in_try && in_try.bfinally) return;
|
||||
var changed = false;
|
||||
for (var index = statements.length; --index >= 0;) {
|
||||
var stat = statements[index];
|
||||
if (!(stat instanceof AST_SimpleStatement)) break;
|
||||
var node = stat.body;
|
||||
if (!(node instanceof AST_Await)) break;
|
||||
var exp = node.expression;
|
||||
if (!is_primitive(compressor, exp)) break;
|
||||
changed = true;
|
||||
exp = exp.drop_side_effect_free(compressor, true);
|
||||
if (exp) {
|
||||
stat.body = exp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
statements.length = index + 1;
|
||||
return changed;
|
||||
}
|
||||
|
||||
function inline_iife(statements, compressor) {
|
||||
var changed = false;
|
||||
var index = statements.length - 1;
|
||||
@@ -12987,6 +13012,14 @@ Compressor.prototype.compress = function(node) {
|
||||
var self = this;
|
||||
var inlined = sync(self.expression).try_inline(compressor, scope, no_return, in_loop);
|
||||
if (!inlined) return;
|
||||
if (!no_return) scan_local_returns(inlined, function(node) {
|
||||
node.in_bool = false;
|
||||
var value = node.value;
|
||||
if (value instanceof AST_Await) return;
|
||||
node.value = make_node(AST_Await, self, {
|
||||
expression: value || make_node(AST_Undefined, node).transform(compressor),
|
||||
});
|
||||
});
|
||||
return aborts(inlined) ? inlined : make_node(AST_BlockStatement, self, {
|
||||
body: [ inlined, make_node(AST_SimpleStatement, self, {
|
||||
body: make_node(AST_Await, self, { expression: make_node(AST_Number, self, { value: 0 })}),
|
||||
|
||||
Reference in New Issue
Block a user