diff options
author | alexlamsl <alexlamsl@gmail.com> | 2017-01-17 17:33:40 +0800 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2017-01-19 21:06:28 +0100 |
commit | 48284844a461e6113bb9911cdcdad7ab8a3d85de (patch) | |
tree | 05c5d8ff7f2a312a8880c143dbfcdf35abe11dd5 /lib/compress.js | |
parent | ec2e5fa3a2e5cf421aebd94b93c668b18e540c69 (diff) | |
download | tracifyjs-48284844a461e6113bb9911cdcdad7ab8a3d85de.tar.gz tracifyjs-48284844a461e6113bb9911cdcdad7ab8a3d85de.zip |
add missing LHS cases which global_defs should avoid
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js index 5879b93b..bbd3659d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -970,6 +970,11 @@ merge(Compressor.prototype, { node.DEFMETHOD("is_string", func); }); + function isLHS(node, parent) { + return parent instanceof AST_Unary && (parent.operator === "++" || parent.operator === "--") + || parent instanceof AST_Assign && parent.left === node; + } + function best_of(ast1, ast2) { return ast1.print_to_string().length > ast2.print_to_string().length @@ -2608,14 +2613,6 @@ merge(Compressor.prototype, { }); OPT(AST_SymbolRef, function(self, compressor){ - function isLHS(symbol, parent) { - return ( - parent instanceof AST_Binary && - parent.operator === '=' && - parent.left === symbol - ); - } - if (self.undeclared() && !isLHS(self, compressor.parent())) { var defines = compressor.option("global_defs"); if (defines && HOP(defines, self.name)) { |