inline single-use functions that are not constant expressions (#2434)
fixes #2428
This commit is contained in:
@@ -150,7 +150,9 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
var passes = +this.options.passes || 1;
|
||||
var last_count = 1 / 0;
|
||||
var mangle = { ie8: this.option("ie8") };
|
||||
for (var pass = 0; pass < passes; pass++) {
|
||||
node.figure_out_scope(mangle);
|
||||
if (pass > 0 || this.option("reduce_vars"))
|
||||
node.reset_opt_flags(this);
|
||||
node = node.transform(this);
|
||||
@@ -3528,6 +3530,7 @@ merge(Compressor.prototype, {
|
||||
&& !exp.uses_arguments
|
||||
&& !exp.uses_eval
|
||||
&& exp.body.length == 1
|
||||
&& !exp.contains_this()
|
||||
&& all(exp.argnames, function(arg) {
|
||||
return arg.__unused;
|
||||
})
|
||||
@@ -3541,23 +3544,6 @@ merge(Compressor.prototype, {
|
||||
expression: stat.body
|
||||
});
|
||||
}
|
||||
if (value) {
|
||||
var tw = new TreeWalker(function(node) {
|
||||
if (!value) return true;
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
var ref = node.scope.find_variable(node);
|
||||
if (ref && ref.scope.parent_scope === fn.parent_scope) {
|
||||
value = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (node instanceof AST_This && !tw.find_parent(AST_Scope)) {
|
||||
value = null;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
value.walk(tw);
|
||||
}
|
||||
if (value) {
|
||||
var args = self.args.concat(value);
|
||||
return make_sequence(self, args).optimize(compressor);
|
||||
|
||||
Reference in New Issue
Block a user