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