enhance side_effects (#3383)

This commit is contained in:
Alex Lam S.L
2019-04-25 04:14:21 +08:00
committed by GitHub
parent c56d89f804
commit a206964c0a
4 changed files with 36 additions and 14 deletions

View File

@@ -4172,10 +4172,18 @@ merge(Compressor.prototype, {
var right = this.right.drop_side_effect_free(compressor, first_in_statement);
if (!right) return this.left.drop_side_effect_free(compressor, first_in_statement);
if (lazy_op[this.operator]) {
if (right === this.right) return this;
var node = this.clone();
node.right = right.drop_side_effect_free(compressor);
return node;
var node;
if (right === this.right) {
node = this;
} else {
node = this.clone();
node.right = right.drop_side_effect_free(compressor);
}
return (first_in_statement ? best_of_statement : best_of_expression)(node, make_node(AST_Binary, this, {
operator: node.operator == "&&" ? "||" : "&&",
left: node.left.negate(compressor, first_in_statement),
right: node.right
}));
} else {
var left = this.left.drop_side_effect_free(compressor, first_in_statement);
if (!left) return right;