minor clean-up for IIFE (#2582)
- faster exact type match - aggressively convert to `!`
This commit is contained in:
@@ -808,10 +808,8 @@ merge(Compressor.prototype, {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function is_iife_call(node) {
|
function is_iife_call(node) {
|
||||||
if (node instanceof AST_Call && !(node instanceof AST_New)) {
|
if (node.TYPE != "Call") return false;
|
||||||
return node.expression instanceof AST_Function || is_iife_call(node.expression);
|
return node.expression instanceof AST_Function || is_iife_call(node.expression);
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_undeclared_ref(node) {
|
function is_undeclared_ref(node) {
|
||||||
@@ -3099,14 +3097,9 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef) return null;
|
if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef) return null;
|
||||||
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
||||||
if (first_in_statement
|
if (first_in_statement && expression && is_iife_call(expression)) {
|
||||||
&& this instanceof AST_UnaryPrefix
|
if (expression === this.expression && this.operator == "!") return this;
|
||||||
&& is_iife_call(expression)) {
|
return expression.negate(compressor, first_in_statement);
|
||||||
if (expression === this.expression && this.operator.length === 1) return this;
|
|
||||||
return make_node(AST_UnaryPrefix, this, {
|
|
||||||
operator: this.operator.length === 1 ? this.operator : "!",
|
|
||||||
expression: expression
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return expression;
|
return expression;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user