use a Dictionary object instead of plain object for hashes
to mitigate the `__proto__` issue related to #30
This commit is contained in:
@@ -1026,7 +1026,7 @@ merge(Compressor.prototype, {
|
||||
if (hoist_funs || hoist_vars) {
|
||||
var dirs = [];
|
||||
var hoisted = [];
|
||||
var vars = {}, vars_found = 0, var_decl = 0;
|
||||
var vars = new Dictionary(), vars_found = 0, var_decl = 0;
|
||||
// let's count var_decl first, we seem to waste a lot of
|
||||
// space if we hoist `var` when there's only one.
|
||||
self.walk(new TreeWalker(function(node){
|
||||
@@ -1051,7 +1051,7 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
if (node instanceof AST_Var && hoist_vars) {
|
||||
node.definitions.forEach(function(def){
|
||||
vars[def.name.name] = def;
|
||||
vars.set(def.name.name, def);
|
||||
++vars_found;
|
||||
});
|
||||
var seq = node.to_assignments();
|
||||
@@ -1075,8 +1075,8 @@ merge(Compressor.prototype, {
|
||||
);
|
||||
self = self.transform(tt);
|
||||
if (vars_found > 0) hoisted.unshift(make_node(AST_Var, self, {
|
||||
definitions: Object.keys(vars).map(function(name){
|
||||
var def = vars[name].clone();
|
||||
definitions: vars.map(function(def){
|
||||
def = def.clone();
|
||||
def.value = null;
|
||||
return def;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user