aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-11-02 10:58:45 +0200
committerMihai Bazon <mihai@bazon.net>2012-11-02 10:58:45 +0200
commit8413787efc6dd570b5cc48dec65e5ffe1a32084a (patch)
tree8682c461ff84f52f806fdbd055d395838f9e9276 /lib/compress.js
parentdde57452aa5c42bddb6865404e75d1b721c26c43 (diff)
downloadtracifyjs-8413787efc6dd570b5cc48dec65e5ffe1a32084a.tar.gz
tracifyjs-8413787efc6dd570b5cc48dec65e5ffe1a32084a.zip
use a Dictionary object instead of plain object for hashes
to mitigate the `__proto__` issue related to #30
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 5ceef200..fe212b42 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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;
})