OPT(AST_Call, function(self, compressor){
var exp = self.expression;
- if (compressor.option("reduce_vars") && exp instanceof AST_SymbolRef) {
- var fixed = exp.fixed_value();
- if (fixed instanceof AST_Function) exp = fixed;
- }
+ var fn = exp;
if (compressor.option("unused")
- && exp instanceof AST_Function
- && !exp.uses_arguments
- && !exp.uses_eval) {
+ && (fn instanceof AST_Function
+ || compressor.option("reduce_vars")
+ && fn instanceof AST_SymbolRef
+ && (fn = fn.fixed_value()) instanceof AST_Function)
+ && !fn.uses_arguments
+ && !fn.uses_eval) {
var pos = 0, last = 0;
for (var i = 0, len = self.args.length; i < len; i++) {
- var trim = i >= exp.argnames.length;
- if (trim || exp.argnames[i].__unused) {
+ var trim = i >= fn.argnames.length;
+ if (trim || fn.argnames[i].__unused) {
var node = self.args[i].drop_side_effect_free(compressor);
if (node) {
self.args[pos++] = node;
}
}
}
- if (exp instanceof AST_Function) {
- var stat = exp.body[0];
- if (compressor.option("inline") && stat instanceof AST_Return) {
- var value = stat && stat.value;
- if (!value || value.is_constant_expression()) {
- var args = self.args.concat(value || make_node(AST_Undefined, self));
- return make_sequence(self, args).transform(compressor);
- }
+ var stat = fn instanceof AST_Function && fn.body[0];
+ if (compressor.option("inline") && stat instanceof AST_Return) {
+ var value = stat.value;
+ if (!value || value.is_constant_expression()) {
+ var args = self.args.concat(value || make_node(AST_Undefined, self));
+ return make_sequence(self, args).transform(compressor);
}
+ }
+ if (exp instanceof AST_Function) {
if (compressor.option("inline")
&& !exp.name
&& exp.body.length == 1