aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-12-22 11:36:45 +0200
committerMihai Bazon <mihai@bazon.net>2013-12-22 11:36:45 +0200
commit5a083a938d8d6eca5c43a5edd1921906299df18f (patch)
tree8b6c0045afdd995d34d6e12af2f3cfda9f3a171f /lib/compress.js
parent7a30d826b89197f7a74001af83676c39277b0eab (diff)
downloadtracifyjs-5a083a938d8d6eca5c43a5edd1921906299df18f.tar.gz
tracifyjs-5a083a938d8d6eca5c43a5edd1921906299df18f.zip
Optimize seq,void 0. Close #377.
(x, void 0) => void x (x, undefined) => void x
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js12
1 files changed, 12 insertions, 0 deletions
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;
});