@@ -6092,6 +6092,30 @@ merge(Compressor.prototype, {
|
||||
});
|
||||
tw.directives = Object.create(compressor.directives);
|
||||
self.walk(tw);
|
||||
var drop_fn_name = compressor.option("keep_fnames") ? return_false : compressor.option("ie8") ? function(def) {
|
||||
return !compressor.exposed(def) && def.references.length == def.replaced;
|
||||
} : function(def) {
|
||||
if (!(def.id in in_use_ids)) return true;
|
||||
if (def.orig.length < 2) return false;
|
||||
// function argument will always overshadow its name
|
||||
if (def.orig[1] instanceof AST_SymbolFunarg) return true;
|
||||
// retain if referenced within destructured object of argument
|
||||
return all(def.references, function(ref) {
|
||||
return !ref.in_arg;
|
||||
});
|
||||
};
|
||||
if (compressor.option("ie8")) initializations.each(function(init, id) {
|
||||
if (id in in_use_ids) return;
|
||||
init.forEach(function(init) {
|
||||
init.walk(new TreeWalker(function(node) {
|
||||
if (node instanceof AST_Function && node.name && !drop_fn_name(node.name.definition())) {
|
||||
node.walk(tw);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Scope) return true;
|
||||
}));
|
||||
});
|
||||
});
|
||||
// pass 2: for every used symbol we need to walk its
|
||||
// initialization code to figure out if it uses other
|
||||
// symbols (that may not be in_use).
|
||||
@@ -6129,18 +6153,6 @@ merge(Compressor.prototype, {
|
||||
delete assign_in_use[id];
|
||||
}
|
||||
});
|
||||
var drop_fn_name = compressor.option("keep_fnames") ? return_false : compressor.option("ie8") ? function(def) {
|
||||
return !compressor.exposed(def) && def.references.length == def.replaced;
|
||||
} : function(def) {
|
||||
if (!(def.id in in_use_ids)) return true;
|
||||
if (def.orig.length < 2) return false;
|
||||
// function argument will always overshadow its name
|
||||
if (def.orig[1] instanceof AST_SymbolFunarg) return true;
|
||||
// retain if referenced within destructured object of argument
|
||||
return all(def.references, function(ref) {
|
||||
return !ref.in_arg;
|
||||
});
|
||||
};
|
||||
// pass 3: we should drop declarations not in_use
|
||||
var trim_defns = [];
|
||||
var unused_fn_names = [];
|
||||
|
||||
Reference in New Issue
Block a user