diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-11 05:59:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-11 05:59:35 +0800 |
commit | 3c740473686178c242f66d3ad330e1b047335b5f (patch) | |
tree | 0ee897d27731ae245c07deeddb06d183f342b976 /lib | |
parent | 94525d859f5db559366f96b646aca84438b0f982 (diff) | |
download | tracifyjs-3c740473686178c242f66d3ad330e1b047335b5f.tar.gz tracifyjs-3c740473686178c242f66d3ad330e1b047335b5f.zip |
implement compress option `reduce_funcs` (#2466)
- inline single-use function declarations as expressions when permissible
- depend on `reduce_vars`
- enabled by default
- disable for speed critical code
fixes #2464
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 24c5be21..2b38ed49 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -75,6 +75,7 @@ function Compressor(options, false_by_default) { properties : !false_by_default, pure_getters : !false_by_default && "strict", pure_funcs : null, + reduce_funcs : !false_by_default, reduce_vars : !false_by_default, sequences : !false_by_default, side_effects : !false_by_default, @@ -4255,6 +4256,7 @@ merge(Compressor.prototype, { var fixed = self.fixed_value(); if (fixed instanceof AST_Defun) { d.fixed = fixed = make_node(AST_Function, fixed, fixed); + if (!compressor.option("reduce_funcs")) d.single_use = false; } if (d.single_use && fixed instanceof AST_Function) { if (d.escaped && d.scope !== self.scope || recursive_ref(compressor, d)) { |