optimise binary operands with evaluate() (#1427)
authorAlex Lam S.L <alexlamsl@gmail.com>
Thu, 26 Jan 2017 11:16:50 +0000 (19:16 +0800)
committerRichard van Velzen <rvanvelzen1@gmail.com>
Thu, 26 Jan 2017 11:16:50 +0000 (12:16 +0100)
commit0610c020b1544820be9898a285ab6c9066490552
tree37d005390ae52fd1efddd3074d855ccba6ca8a0c
parent0d7d4918eb6fb73c3cf9863479b3e66d38fad6df
optimise binary operands with evaluate() (#1427)

- remove call to evaluate() in is_constant() and let nested optimize() does its job instead
- reject RegExp in is_constant() and remove special case logic under collapse_vars
- operands to conditionals optimisation are now always evaluate()-ed
- throw error in constant_value() instead of returning undefined to catch possible bugs, similar to make_node_from_constant()
- optimise binary boolean operators under `evaluate` instead of `conditionals`
lib/compress.js
test/compress/conditionals.js
test/compress/evaluate.js
test/compress/reduce_vars.js