minor clean-ups to evaluate (#2197)

This commit is contained in:
Alex Lam S.L
2017-07-03 18:52:39 +08:00
committed by GitHub
parent af0262b7e5
commit 5f046c724b

View File

@@ -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){