diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-07-03 18:52:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-03 18:52:39 +0800 |
commit | 5f046c724bf0910e6ee7c1c3feabaf62625fa1c6 (patch) | |
tree | 53d8c7d6ad8874e6e19ebc1b7cccb4dd9e382ab4 | |
parent | af0262b7e5fd3dbf83619cdb375ab18c41def3e7 (diff) | |
download | tracifyjs-5f046c724bf0910e6ee7c1c3feabaf62625fa1c6.tar.gz tracifyjs-5f046c724bf0910e6ee7c1c3feabaf62625fa1c6.zip |
minor clean-ups to `evaluate` (#2197)
-rw-r--r-- | lib/compress.js | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/lib/compress.js b/lib/compress.js index f0aedf57..733abf45 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1692,12 +1692,9 @@ merge(Compressor.prototype, { }); def(AST_SymbolRef, function(compressor){ if (!compressor.option("reduce_vars")) return this; - this._eval = return_this; var fixed = this.fixed_value(); - if (!fixed) { - delete this._eval; - return this; - } + if (!fixed) return this; + this._eval = return_this; var value = ev(fixed, compressor); if (value === fixed) { delete this._eval; @@ -1729,41 +1726,41 @@ merge(Compressor.prototype, { return this; }); var object_fns = [ - 'constructor', - 'toString', - 'valueOf', + "constructor", + "toString", + "valueOf", ]; var native_fns = { Array: makePredicate([ - 'indexOf', - 'join', - 'lastIndexOf', - 'slice', + "indexOf", + "join", + "lastIndexOf", + "slice", ].concat(object_fns)), Boolean: makePredicate(object_fns), Number: makePredicate([ - 'toExponential', - 'toFixed', - 'toPrecision', + "toExponential", + "toFixed", + "toPrecision", ].concat(object_fns)), RegExp: makePredicate([ - 'test', + "test", ].concat(object_fns)), String: makePredicate([ - 'charAt', - 'charCodeAt', - 'concat', - 'indexOf', - 'italics', - 'lastIndexOf', - 'match', - 'replace', - 'search', - 'slice', - 'split', - 'substr', - 'substring', - 'trim', + "charAt", + "charCodeAt", + "concat", + "indexOf", + "italics", + "lastIndexOf", + "match", + "replace", + "search", + "slice", + "split", + "substr", + "substring", + "trim", ].concat(object_fns)), }; def(AST_Call, function(compressor){ |