From 5a083a938d8d6eca5c43a5edd1921906299df18f Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Sun, 22 Dec 2013 11:36:45 +0200 Subject: [PATCH] Optimize seq,void 0. Close #377. (x, void 0) => void x (x, undefined) => void x --- lib/compress.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index 2a8b4c2e..a3ba16ab 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1836,6 +1836,18 @@ merge(Compressor.prototype, { return self.car; } } + if (self.cdr instanceof AST_UnaryPrefix + && self.cdr.operator == "void" + && !self.cdr.expression.has_side_effects(compressor)) { + self.cdr.operator = self.car; + return self.cdr; + } + if (self.cdr instanceof AST_Undefined) { + return make_node(AST_UnaryPrefix, self, { + operator : "void", + expression : self.car + }); + } return self; }); -- 2.34.1