[Pkg-javascript-commits] [uglifyjs] 470/491: improve exceptional flow compression by `collapse_vars` (#2880)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:52:05 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit 3026bd89759446c9c5d6fa1cd69651f853ffe08d
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Sun Feb 4 04:18:22 2018 +0800
improve exceptional flow compression by `collapse_vars` (#2880)
---
lib/compress.js | 13 +++----------
test/compress/collapse_vars.js | 18 ++++++------------
2 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index f9cd7a4..321ee5f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1408,22 +1408,15 @@ merge(Compressor.prototype, {
}
function side_effects_external(node, lhs) {
- if (node instanceof AST_Assign) {
- return side_effects_external(node.left, true)
- || side_effects_external(node.right);
- }
- if (node instanceof AST_Definitions) return false;
+ if (node instanceof AST_Assign) return side_effects_external(node.left, true);
if (node instanceof AST_Unary) return side_effects_external(node.expression, true);
if (node instanceof AST_VarDef) return node.value && side_effects_external(node.value);
if (lhs) {
if (node instanceof AST_Dot) return side_effects_external(node.expression, true);
- if (node instanceof AST_Sub) {
- return side_effects_external(node.expression, true)
- || side_effects_external(node.property);
- }
+ if (node instanceof AST_Sub) return side_effects_external(node.expression, true);
if (node instanceof AST_SymbolRef) return node.definition().scope !== scope;
}
- return node.has_side_effects(compressor);
+ return false;
}
}
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 4191de8..19db605 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -4281,19 +4281,16 @@ cond_branch_1: {
}
expect: {
function f1(b, c) {
- var log = console.log;
if (b) b++;
- log(++c, b);
+ (0, console.log)(++c, b);
}
function f2(b, c) {
- var log = console.log;
b && b++,
- log(++c, b);
+ (0, console.log)(++c, b);
}
function f3(b, c) {
- var log = console.log;
b ? b++ : b--,
- log(++c, b);
+ (0, console.log)(++c, b);
}
f1(1, 2),
f2(3, 4),
@@ -4337,22 +4334,19 @@ cond_branch_2: {
}
expect: {
function f1(b, c) {
- var log = console.log;
var a = ++c;
if (b) b += a;
- log(a, b);
+ (0, console.log)(a, b);
}
function f2(b, c) {
- var log = console.log;
var a = ++c;
b && (b += a),
- log(a, b);
+ (0, console.log)(a, b);
}
function f3(b, c) {
- var log = console.log;
var a = ++c;
b ? b += a : b--,
- log(a, b);
+ (0, console.log)(a, b);
}
f1(1, 2),
f2(3, 4),
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list