trim unused invocation parameters (#1526)
This commit is contained in:
@@ -2481,6 +2481,20 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
OPT(AST_Call, function(self, compressor){
|
OPT(AST_Call, function(self, compressor){
|
||||||
|
if (compressor.option("unused")
|
||||||
|
&& self.expression instanceof AST_Function
|
||||||
|
&& !self.expression.uses_arguments
|
||||||
|
&& !self.expression.uses_eval
|
||||||
|
&& self.args.length > self.expression.argnames.length) {
|
||||||
|
var end = self.expression.argnames.length;
|
||||||
|
for (var i = end, len = self.args.length; i < len; i++) {
|
||||||
|
var node = self.args[i].drop_side_effect_free(compressor);
|
||||||
|
if (node) {
|
||||||
|
self.args[end++] = node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.args.length = end;
|
||||||
|
}
|
||||||
if (compressor.option("unsafe")) {
|
if (compressor.option("unsafe")) {
|
||||||
var exp = self.expression;
|
var exp = self.expression;
|
||||||
if (exp instanceof AST_SymbolRef && exp.undeclared()) {
|
if (exp instanceof AST_SymbolRef && exp.undeclared()) {
|
||||||
|
|||||||
@@ -646,6 +646,29 @@ call_args: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
call_args_drop_param: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
keep_fargs: false,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
const a = 1;
|
||||||
|
console.log(a);
|
||||||
|
+function(a) {
|
||||||
|
return a;
|
||||||
|
}(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
const a = 1;
|
||||||
|
console.log(1);
|
||||||
|
+function() {
|
||||||
|
return 1;
|
||||||
|
}(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
in_boolean_context: {
|
in_boolean_context: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user