diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0f72404f..2577643b 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -373,6 +373,7 @@ merge(Compressor.prototype, { } } if (node instanceof AST_Defun) { + node.inlined = false; var d = node.name.definition(); if (compressor.exposed(d) || safe_to_read(d)) { d.fixed = false; @@ -389,6 +390,7 @@ merge(Compressor.prototype, { return true; } if (node instanceof AST_Function) { + node.inlined = false; push(); var iife; if (!node.name @@ -4329,16 +4331,21 @@ merge(Compressor.prototype, { d.fixed = fixed = make_node(AST_Function, fixed, fixed); } if (d.single_use && fixed instanceof AST_Function) { - if (!compressor.option("reduce_funcs") && d.scope !== self.scope) { + if (d.scope !== self.scope + && (!compressor.option("reduce_funcs") + || d.escaped + || fixed.inlined)) { d.single_use = false; - } else if (d.escaped && d.scope !== self.scope || recursive_ref(compressor, d)) { + } else if (recursive_ref(compressor, d)) { d.single_use = false; } else if (d.scope !== self.scope || d.orig[0] instanceof AST_SymbolFunarg) { d.single_use = fixed.is_constant_expression(self.scope); if (d.single_use == "f") { var scope = self.scope; do { - if (scope.name) scope.name.definition().single_use = false; + if (scope instanceof AST_Defun || scope instanceof AST_Function) { + scope.inlined = true; + } } while (scope = scope.parent_scope); } } |