minor clean-up (#5180)
This commit is contained in:
@@ -9589,7 +9589,10 @@ merge(Compressor.prototype, {
|
||||
var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor);
|
||||
if (can_inline && stat instanceof AST_Return) {
|
||||
var value = stat.value;
|
||||
if (exp === fn && !fn.name && (!value || value.is_constant_expression()) && safe_from_await_yield(fn)) {
|
||||
if (exp === fn
|
||||
&& !fn.name
|
||||
&& (!value || value.is_constant_expression())
|
||||
&& safe_from_await_yield(fn, compressor.find_parent(AST_Scope))) {
|
||||
return make_sequence(self, convert_args(value)).optimize(compressor);
|
||||
}
|
||||
}
|
||||
@@ -9669,7 +9672,7 @@ merge(Compressor.prototype, {
|
||||
&& all(fn.body, is_empty)
|
||||
&& (fn === exp ? fn_name_unused(fn, compressor) : !has_default && !has_destructured && !fn.rest)
|
||||
&& !(is_arrow(fn) && fn.value)
|
||||
&& safe_from_await_yield(fn)) {
|
||||
&& safe_from_await_yield(fn, compressor.find_parent(AST_Scope))) {
|
||||
return make_sequence(self, convert_args()).optimize(compressor);
|
||||
}
|
||||
}
|
||||
@@ -9777,8 +9780,8 @@ merge(Compressor.prototype, {
|
||||
return args;
|
||||
}
|
||||
|
||||
function safe_from_await_yield(node) {
|
||||
var avoid = avoid_await_yield(scope || compressor.find_parent(AST_Scope));
|
||||
function safe_from_await_yield(node, scope) {
|
||||
var avoid = avoid_await_yield(scope);
|
||||
if (!avoid) return true;
|
||||
var safe = true;
|
||||
var tw = new TreeWalker(function(node) {
|
||||
@@ -9854,8 +9857,9 @@ merge(Compressor.prototype, {
|
||||
if (!fn.variables.all(function(def) {
|
||||
return def.references.length - def.replaced < 2 && def.orig[0] instanceof AST_SymbolFunarg;
|
||||
})) return;
|
||||
var scope = compressor.find_parent(AST_Scope);
|
||||
var abort = false;
|
||||
var avoid = avoid_await_yield(scope || compressor.find_parent(AST_Scope));
|
||||
var avoid = avoid_await_yield(scope);
|
||||
var begin;
|
||||
var in_order = [];
|
||||
var side_effects = false;
|
||||
@@ -9899,8 +9903,7 @@ merge(Compressor.prototype, {
|
||||
while (end-- > begin && fn.argnames[end] === in_order.pop());
|
||||
end++;
|
||||
}
|
||||
var scope = side_effects && !in_order && compressor.find_parent(AST_Scope);
|
||||
return end <= begin || all(self.args.slice(begin, end), scope ? function(funarg) {
|
||||
return end <= begin || all(self.args.slice(begin, end), side_effects && !in_order ? function(funarg) {
|
||||
return funarg.is_constant_expression(scope);
|
||||
} : function(funarg) {
|
||||
return !funarg.has_side_effects(compressor);
|
||||
@@ -9970,7 +9973,7 @@ merge(Compressor.prototype, {
|
||||
} while (!(scope instanceof AST_Scope));
|
||||
insert = scope.body.indexOf(child) + 1;
|
||||
if (!insert) return false;
|
||||
if (!safe_from_await_yield(fn)) return false;
|
||||
if (!safe_from_await_yield(fn, scope)) return false;
|
||||
var safe_to_inject = exp !== fn || fn.parent_scope.resolve() === scope;
|
||||
if (scope instanceof AST_Toplevel) {
|
||||
if (compressor.toplevel.vars) {
|
||||
@@ -12374,13 +12377,14 @@ merge(Compressor.prototype, {
|
||||
if (prop.key !== key) continue;
|
||||
if (!all(props, can_hoist_property)) return;
|
||||
if (!safe_to_flatten(prop.value, compressor)) return;
|
||||
var values = [];
|
||||
var scope, values = [];
|
||||
for (var j = 0; j < props.length; j++) {
|
||||
var value = props[j].value;
|
||||
if (props[j] instanceof AST_ObjectMethod) {
|
||||
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
|
||||
if (arrow) {
|
||||
var avoid = avoid_await_yield(compressor.find_parent(AST_Scope));
|
||||
if (!scope) scope = compressor.find_parent(AST_Scope);
|
||||
var avoid = avoid_await_yield(scope);
|
||||
value.each_argname(function(argname) {
|
||||
if (avoid[argname.name]) arrow = false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user