From: Alex Lam S.L Date: Mon, 3 Jul 2017 10:52:39 +0000 (+0800) Subject: minor clean-ups to `evaluate` (#2197) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5f046c724bf0910e6ee7c1c3feabaf62625fa1c6;p=UglifyJS.git minor clean-ups to `evaluate` (#2197) --- 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){