minor clean-ups (#5300)
This commit is contained in:
@@ -2530,7 +2530,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
if (names.has(sym.name)) continue;
|
||||
names.set(sym.name, true);
|
||||
if (value) arg = !arg || is_undefined(arg) ? value : null;
|
||||
if (value) arg = is_undefined(arg) ? value : null;
|
||||
if (!arg && !value) {
|
||||
arg = make_node(AST_Undefined, sym).transform(compressor);
|
||||
} else if (arg instanceof AST_Lambda && arg.pinned()) {
|
||||
@@ -3423,10 +3423,6 @@ Compressor.prototype.compress = function(node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_return_void(value) {
|
||||
return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
|
||||
}
|
||||
|
||||
function match_target(target) {
|
||||
return last_of(compressor, function(node) {
|
||||
return node === target;
|
||||
@@ -3434,7 +3430,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
|
||||
function can_drop_abort(ab) {
|
||||
if (ab instanceof AST_Return) return in_lambda && is_return_void(ab.value);
|
||||
if (ab instanceof AST_Return) return in_lambda && is_undefined(ab.value);
|
||||
if (!(ab instanceof AST_LoopControl)) return false;
|
||||
var lct = compressor.loopcontrol_target(ab);
|
||||
if (ab instanceof AST_Continue) return match_target(loop_body(lct));
|
||||
@@ -3481,9 +3477,7 @@ Compressor.prototype.compress = function(node) {
|
||||
block = last.body;
|
||||
}
|
||||
block.pop();
|
||||
if (ab.value) block.push(make_node(AST_SimpleStatement, ab.value, {
|
||||
body: ab.value.expression
|
||||
}));
|
||||
if (ab.value) block.push(make_node(AST_SimpleStatement, ab.value, { body: ab.value }));
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -4000,7 +3994,8 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
|
||||
function is_undefined(node, compressor) {
|
||||
return node.is_undefined
|
||||
return node == null
|
||||
|| node.is_undefined
|
||||
|| node instanceof AST_Undefined
|
||||
|| node instanceof AST_UnaryPrefix
|
||||
&& node.operator == "void"
|
||||
@@ -9915,7 +9910,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (argname instanceof AST_DefaultValue) {
|
||||
if (!has_default) has_default = 1;
|
||||
var arg = has_default == 1 && self.args[index];
|
||||
if (arg && !is_undefined(arg)) has_default = 2;
|
||||
if (!is_undefined(arg)) has_default = 2;
|
||||
if (has_arg_refs(fn, argname.value)) return false;
|
||||
argname = argname.name;
|
||||
}
|
||||
@@ -13176,7 +13171,6 @@ Compressor.prototype.compress = function(node) {
|
||||
if (!no_return) {
|
||||
if (async) scan_local_returns(inlined, function(node) {
|
||||
var value = node.value;
|
||||
if (!value) return;
|
||||
if (is_undefined(value)) return;
|
||||
node.value = make_node(AST_Await, call, { expression: value });
|
||||
});
|
||||
@@ -13320,10 +13314,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (!no_return) scan_local_returns(inlined, function(node) {
|
||||
node.in_bool = false;
|
||||
var value = node.value;
|
||||
if (op == "void") {
|
||||
if (!value) return;
|
||||
if (is_undefined(value)) return;
|
||||
}
|
||||
if (op == "void" && is_undefined(value)) return;
|
||||
node.value = make_node(AST_UnaryPrefix, self, {
|
||||
operator: op,
|
||||
expression: value || make_node(AST_Undefined, node).transform(compressor),
|
||||
@@ -13371,8 +13362,7 @@ Compressor.prototype.compress = function(node) {
|
||||
|
||||
OPT(AST_Return, function(self, compressor) {
|
||||
var value = self.value;
|
||||
if (compressor.option("side_effects")
|
||||
&& value
|
||||
if (value && compressor.option("side_effects")
|
||||
&& is_undefined(value, compressor)
|
||||
&& !in_async_generator(compressor.find_parent(AST_Scope))) {
|
||||
self.value = null;
|
||||
|
||||
Reference in New Issue
Block a user