add option to mangle names even if eval/with is in use

(for more fair comparison to Closure compiler)
This commit is contained in:
Mihai Bazon
2012-11-06 11:39:41 +02:00
parent 7f5f4d60b7
commit a4f6d46118
3 changed files with 44 additions and 21 deletions

View File

@@ -247,16 +247,30 @@ function makePredicate(words) {
function Dictionary() {
this._values = Object.create(null);
this._size = 0;
};
Dictionary.prototype = {
set: function(key, val) { return this._values["$" + key] = val, this },
set: function(key, val) {
if (!this.has(key)) ++this._size;
this._values["$" + key] = val;
return this;
},
get: function(key) { return this._values["$" + key] },
del: function(key) { return delete this._values["$" + key], this },
del: function(key) {
if (this.has(key)) {
--this._size;
delete this._values["$" + key];
}
return this;
},
has: function(key) { return ("$" + key) in this._values },
each: function(f) {
for (var i in this._values)
f(this._values[i], i.substr(1));
},
size: function() {
return this._size;
},
map: function(f) {
var ret = [];
for (var i in this._values)