diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-23 16:06:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-23 23:06:12 +0800 |
commit | 7de8daa4b151fc47080d5a5f6329c3f80b9a5e7d (patch) | |
tree | f4a2eced55b91071b7277165e1407780a94375c0 /lib/scope.js | |
parent | 305a4bdceef9183561f3145fe60c80c4e76d752a (diff) | |
download | tracifyjs-7de8daa4b151fc47080d5a5f6329c3f80b9a5e7d.tar.gz tracifyjs-7de8daa4b151fc47080d5a5f6329c3f80b9a5e7d.zip |
minor clean up (#4149)
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/scope.js b/lib/scope.js index ec69eb1b..405f563d 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -335,7 +335,7 @@ AST_Toplevel.DEFMETHOD("resolve", return_this); function names_in_use(scope, options) { var names = scope.names_in_use; if (!names) { - scope.names_in_use = names = Object.create(scope.mangled_names || null); + scope.names_in_use = names = Object.create(null); scope.cname_holes = []; var cache = options.cache && options.cache.props; scope.enclosed.forEach(function(def) { @@ -369,7 +369,7 @@ function next_mangled_name(scope, options, def) { name = base54(holes[i]); if (names[name]) continue; holes.splice(i, 1); - scope.names_in_use[name] = true; + in_use[name] = true; return name; } while (true) { @@ -378,7 +378,7 @@ function next_mangled_name(scope, options, def) { if (!names[name]) break; holes.push(scope.cname); } - scope.names_in_use[name] = true; + in_use[name] = true; return name; } @@ -419,7 +419,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { var lname = -1; if (options.cache && options.cache.props) { - var mangled_names = this.mangled_names = Object.create(null); + var mangled_names = names_in_use(this, options); options.cache.props.each(function(mangled_name) { mangled_names[mangled_name] = true; }); @@ -491,7 +491,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) { var cache = options.cache && options.cache.props; - var avoid = Object.create(null); + var avoid = Object.create(RESERVED_WORDS); options.reserved.forEach(to_avoid); this.globals.each(add_def); this.walk(new TreeWalker(function(node) { @@ -528,7 +528,7 @@ AST_Toplevel.DEFMETHOD("expand_names", function(options) { var name; do { name = base54(cname++); - } while (avoid[name] || RESERVED_WORDS[name]); + } while (avoid[name]); return name; } |