drop_funcs = drop_vars = true;
}
var in_use = [];
- var in_use_ids = {}; // avoid expensive linear scans of in_use
+ var in_use_ids = Object.create(null); // avoid expensive linear scans of in_use
if (self instanceof AST_Toplevel && compressor.top_retain) {
self.variables.each(function(def) {
if (compressor.top_retain(def) && !(def.id in in_use_ids)) {
// pass 3: we should drop declarations not in_use
var tt = new TreeTransformer(
function before(node, descend, in_list) {
+ if (node instanceof AST_Function
+ && node.name
+ && !compressor.option("keep_fnames")
+ && !(node.name.definition().id in in_use_ids)) {
+ node.name = null;
+ }
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
if (!compressor.option("keep_fargs")) {
for (var a = node.argnames, i = a.length; --i >= 0;) {
var sym = a[i];
- if (sym.unreferenced()) {
+ if (!(sym.definition().id in in_use_ids)) {
a.pop();
compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
name : sym.name,
return self;
});
- OPT(AST_Function, function(self, compressor){
- self = AST_Lambda.prototype.optimize.call(self, compressor);
- if (compressor.option("unused") && !compressor.option("keep_fnames")) {
- if (self.name && self.name.unreferenced()) {
- self.name = null;
- }
- }
- return self;
- });
-
OPT(AST_Call, function(self, compressor){
if (compressor.option("unsafe")) {
var exp = self.expression;