From a16d1d1d1244c3ed75369a7f0113ddac6b00abe7 Mon Sep 17 00:00:00 2001 From: Tal Ater Date: Sat, 27 Sep 2014 02:49:10 +0300 Subject: [PATCH] Reverted previous addition of compression of conditionals where the condition and consequent are equivalent. --- lib/compress.js | 9 --------- test/compress/conditionals.js | 36 ----------------------------------- 2 files changed, 45 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index ac5d0d50..bf2d166e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2332,15 +2332,6 @@ merge(Compressor.prototype, { } } - // x=y?y:z --> x=y||z - if (self.condition.equivalent_to(consequent) - && !self.condition.has_side_effects(compressor)) { - return make_node(AST_Binary, self.condition, { - left: self.condition, - operator: "||", - right: alternative - }); - } // x=y?true:false --> x=!!y if (consequent instanceof AST_True && alternative instanceof AST_False) { diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index ce749ed6..d9c75f18 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -294,42 +294,6 @@ cond_7: { } cond_8: { - options = { - conditionals: true, - evaluate : true - }; - input: { - // compress these - a = condition ? condition : b; - - if (condition) { - a = condition; - } else { - a = b; - } - - a = condition ? condition : b(); - - // Don't compress conditions that have side effects - if (condition()) { - a = condition(); - } else { - a = b; - } - - a = condition() ? condition() : b; - - } - expect: { - a = condition || b; - a = condition || b; - a = condition || b(); - a = condition() ? condition() : b; - a = condition() ? condition() : b; - } -} - -cond_9: { options = { conditionals: true, evaluate : true