aboutsummaryrefslogtreecommitdiff
path: root/lib
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 /lib
parentae51f76ba7568e01b185cb4b6c6e16dee0bf5300 (diff)
downloadtracifyjs-689f8f504d03d47f184c45c85d0b3eb597fafe85.tar.gz
tracifyjs-689f8f504d03d47f184c45c85d0b3eb597fafe85.zip
enhance `mangle` (#4926)
Diffstat (limited to 'lib')
-rw-r--r--lib/scope.js15
1 files changed, 6 insertions, 9 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;