Skip to content

Commit

Permalink
enhance mangle (#4926)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed May 11, 2021
1 parent ae51f76 commit 689f8f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 6 additions & 9 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/mocha/let.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 689f8f5

Please sign in to comment.