aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-11 16:41:32 +0100
committerGitHub <noreply@github.com>2021-05-11 23:41:32 +0800
commit689f8f504d03d47f184c45c85d0b3eb597fafe85 (patch)
treec5cddda9e6726c6c9e74389cf7333a0a9650f7c8
parentae51f76ba7568e01b185cb4b6c6e16dee0bf5300 (diff)
downloadtracifyjs-689f8f504d03d47f184c45c85d0b3eb597fafe85.tar.gz
tracifyjs-689f8f504d03d47f184c45c85d0b3eb597fafe85.zip
enhance `mangle` (#4926)
-rw-r--r--lib/scope.js15
-rw-r--r--test/mocha/let.js4
2 files changed, 8 insertions, 11 deletions
diff --git a/lib/scope.js b/lib/scope.js
index f0d4c921..bb36583c 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -800,6 +800,7 @@ var base54 = (function() {
var leading = init("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_");
var chars, frequency;
function reset() {
+ chars = null;
frequency = Object.create(freq);
}
base54.consider = function(str, delta) {
@@ -811,19 +812,15 @@ var base54 = (function() {
return frequency[b] - frequency[a];
}
base54.sort = function() {
- chars = leading.sort(compare).concat(digits.sort(compare));
+ chars = leading.sort(compare).concat(digits).sort(compare);
};
base54.reset = reset;
reset();
function base54(num) {
- var ret = "", base = 54;
- num++;
- do {
- num--;
- ret += chars[num % base];
- num = Math.floor(num / base);
- base = 64;
- } while (num > 0);
+ var ret = leading[num % 54];
+ for (num = Math.floor(num / 54); --num >= 0; num >>= 6) {
+ ret += chars[num & 0x3F];
+ }
return ret;
}
return base54;
diff --git a/test/mocha/let.js b/test/mocha/let.js
index 09e84b74..fd8bd57a 100644
--- a/test/mocha/let.js
+++ b/test/mocha/let.js
@@ -7,11 +7,11 @@ describe("let", function() {
// Produce a lot of variables in a function and run it through mangle.
var s = '"dddddeeeeelllllooooottttt"; function foo() {';
for (var i = 0; i < 18000; i++) {
- s += "var v" + i + "=0;";
+ s += "var v" + i + "=[];";
}
s += '}';
var result = UglifyJS.minify(s, {
- compress: false
+ compress: false,
}).code;
// Verify that select keywords and reserved keywords not produced