aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-04-03 15:15:01 +0800
committerGitHub <noreply@github.com>2018-04-03 15:15:01 +0800
commit81603ecd156f494a6b0c02655c5361152711300d (patch)
treefe288905905789ee165daee0fcdbef5f48f84cbb /lib/scope.js
parente67553fa550ad355aa1946b5da5051434259a6ba (diff)
downloadtracifyjs-81603ecd156f494a6b0c02655c5361152711300d.tar.gz
tracifyjs-81603ecd156f494a6b0c02655c5361152711300d.zip
improve performance through `makePredicate()` (#3048)
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/scope.js b/lib/scope.js
index a9431524..2c325f68 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -344,7 +344,7 @@ function next_mangled_name(scope, options, def) {
}
while (true) {
name = base54(++scope.cname);
- if (in_use[name] || !is_identifier(name) || member(name, options.reserved)) continue;
+ if (in_use[name] || !is_identifier(name) || options._reserved[name]) continue;
if (!names[name]) break;
holes.push(scope.cname);
}
@@ -387,6 +387,7 @@ function _default_mangler_options(options) {
if (!Array.isArray(options.reserved)) options.reserved = [];
// Never mangle arguments
push_uniq(options.reserved, "arguments");
+ options._reserved = makePredicate(options.reserved);
return options;
}
@@ -452,9 +453,8 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
redefined.forEach(mangle);
function mangle(def) {
- if (!member(def.name, options.reserved)) {
- def.mangle(options);
- }
+ if (options._reserved[def.name]) return;
+ def.mangle(options);
}
});
@@ -504,7 +504,7 @@ AST_Toplevel.DEFMETHOD("expand_names", function(options) {
function rename(def) {
if (def.global && options.cache) return;
if (def.unmangleable(options)) return;
- if (member(def.name, options.reserved)) return;
+ if (options._reserved[def.name]) return;
var d = def.redefined();
def.name = d ? d.name : next_name();
def.orig.forEach(function(sym) {