[Pkg-javascript-commits] [uglifyjs] 456/491: improve symbol replacement heuristic (#2851)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:52:04 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 541e6011af7647074a41c5a82a0a16a3d32bb8c6
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Mon Jan 29 17:41:15 2018 +0800
improve symbol replacement heuristic (#2851)
---
lib/compress.js | 2 +-
test/compress/reduce_vars.js | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 81af151..d0ef5f5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5237,7 +5237,7 @@ merge(Compressor.prototype, {
var name_length = d.name.length;
var overhead = 0;
if (compressor.option("unused") && !compressor.exposed(d)) {
- overhead = (name_length + 2 + value_length) / d.references.length;
+ overhead = (name_length + 2 + value_length) / (d.references.length - d.assignments);
}
d.should_replace = value_length <= name_length + overhead ? fn : false;
} else {
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 2231587..2e562f9 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5435,3 +5435,35 @@ lvalues_def_2: {
}
expect_stdout: "2 NaN"
}
+
+chained_assignments: {
+ options = {
+ evaluate: true,
+ inline: true,
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ toplevel: true,
+ unsafe: true,
+ unused: true,
+ }
+ input: {
+ function f() {
+ var a = [0x5e, 0xad, 0xbe, 0xef];
+ var b = 0;
+ b |= a[0];
+ b <<= 8;
+ b |= a[1];
+ b <<= 8;
+ b |= a[2];
+ b <<= 8;
+ b |= a[3];
+ return b;
+ }
+ console.log(f().toString(16));
+ }
+ expect: {
+ console.log("5eadbeef");
+ }
+ expect_stdout: "5eadbeef"
+}
--
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