diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-14 13:19:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-14 13:19:05 +0800 |
commit | 381bd3836ecd79eb5d4f7b84807c778ee1acf9c9 (patch) | |
tree | 0b67da89eaf6fb1a2381141573eb2e395af7f368 /lib/compress.js | |
parent | 919d5e348249f7b8c5ef0581660817292b5308a6 (diff) | |
download | tracifyjs-381bd3836ecd79eb5d4f7b84807c778ee1acf9c9.tar.gz tracifyjs-381bd3836ecd79eb5d4f7b84807c778ee1acf9c9.zip |
minor clean-ups (#1600)
- remove obsolete optimisation in `AST_Binary` after #1477
- improve `TreeWalker.has_directive()` readability and resilience against multiple visits
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/lib/compress.js b/lib/compress.js index e3ae5bde..ab4c3c2f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1664,7 +1664,7 @@ merge(Compressor.prototype, { /* -----[ optimizers ]----- */ OPT(AST_Directive, function(self, compressor){ - if (compressor.has_directive(self.value) === "up") { + if (compressor.has_directive(self.value) !== self) { return make_node(AST_EmptyStatement, self); } return self; @@ -3018,16 +3018,6 @@ merge(Compressor.prototype, { var commutativeOperators = makePredicate("== === != !== * & | ^"); OPT(AST_Binary, function(self, compressor){ - var lhs = self.left.evaluate(compressor); - var rhs = self.right.evaluate(compressor); - if (lhs.length > 1 && lhs[0].is_constant() !== self.left.is_constant() - || rhs.length > 1 && rhs[0].is_constant() !== self.right.is_constant()) { - return make_node(AST_Binary, self, { - operator: self.operator, - left: lhs[0], - right: rhs[0] - }).optimize(compressor); - } function reversible() { return self.left instanceof AST_Constant || self.right instanceof AST_Constant |