diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-10-13 02:33:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 09:33:49 +0800 |
commit | 3096f6fdad2d92b822ab75bbe78903c152e6b844 (patch) | |
tree | 090f5ef41ee2b49c09f007b4d9846fd98aed3425 /lib/compress.js | |
parent | 176c09c6a5408ef0a8ddca8da7eb930c9d5e2745 (diff) | |
download | tracifyjs-3096f6fdad2d92b822ab75bbe78903c152e6b844.tar.gz tracifyjs-3096f6fdad2d92b822ab75bbe78903c152e6b844.zip |
restore `inline` functionality disabled by #4204 (#4209)
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js index c59e26ed..2307abc7 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -7069,7 +7069,7 @@ merge(Compressor.prototype, { return node; } } - var scope, in_loop, level = -1; + var child, in_loop, scope; if (replacing && can_inject_symbols()) { fn._squeezed = true; if (exp !== fn) fn.parent_scope = exp.scope; @@ -7239,14 +7239,14 @@ merge(Compressor.prototype, { function can_inject_symbols() { var defined = Object.create(null); - var child; + var level = 0; scope = compressor.self(); - do { - child = scope; - scope = compressor.parent(++level); + while (!(scope instanceof AST_Scope)) { if (scope.variables) scope.variables.each(function(def) { defined[def.name] = true; }); + child = scope; + scope = compressor.parent(level++); if (scope instanceof AST_DWLoop) { in_loop = []; } else if (scope instanceof AST_For) { @@ -7259,7 +7259,7 @@ merge(Compressor.prototype, { } else if (scope instanceof AST_SymbolRef) { if (scope.fixed_value() instanceof AST_Scope) return false; } - } while (!(scope instanceof AST_Scope)); + } var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars) && (exp !== fn || fn.parent_scope.resolve() === compressor.find_parent(AST_Scope)); var inline = compressor.option("inline"); @@ -7362,7 +7362,7 @@ merge(Compressor.prototype, { return true; } }); - args.unshift(scope.body.indexOf(compressor.parent(level - 1)) + 1, 0); + args.unshift(scope.body.indexOf(child) + 1, 0); if (decls.length) args.push(make_node(AST_Var, fn, { definitions: decls })); |