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