aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-02 11:33:59 +0800
committerGitHub <noreply@github.com>2017-03-02 11:33:59 +0800
commit9699ffb1afc8bead9fbc3643c6b90b14169ef02c (patch)
tree321a3ee8f7a868e9ec620b266824c0248914b826 /lib/compress.js
parentfdc9b9413bfddc711fe6195bd4fd408ab1dfa95e (diff)
downloadtracifyjs-9699ffb1afc8bead9fbc3643c6b90b14169ef02c.tar.gz
tracifyjs-9699ffb1afc8bead9fbc3643c6b90b14169ef02c.zip
trim unused invocation parameters (#1526)
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 1d4e719a..ddf2b10d 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2481,6 +2481,20 @@ merge(Compressor.prototype, {
});
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")) {
var exp = self.expression;
if (exp instanceof AST_SymbolRef && exp.undeclared()) {