diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-04-25 04:14:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 04:14:21 +0800 |
commit | a206964c0a69776e498ba838e55d0f85946cd27e (patch) | |
tree | 7ed1a96e5ed372099935193d370f8a5150abc2ff /lib | |
parent | c56d89f804e852f8678fa7557f781de893c138bf (diff) | |
download | tracifyjs-a206964c0a69776e498ba838e55d0f85946cd27e.tar.gz tracifyjs-a206964c0a69776e498ba838e55d0f85946cd27e.zip |
enhance `side_effects` (#3383)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0a195940..13fc953d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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; |