refactor(collection): use Map instead of Object

This commit is contained in:
vsavkin
2014-10-18 17:50:55 -04:00
parent 1f4caa8773
commit 2a4b63b614
4 changed files with 11 additions and 12 deletions

View File

@ -45,7 +45,7 @@ export class Injector {
_createListOfBindings(flattenBindings):List {
var bindings = ListWrapper.createFixedSize(Key.numberOfKeys() + 1);
MapWrapper.forEach(flattenBindings, (keyId, v) => bindings[keyId] = v);
MapWrapper.forEach(flattenBindings, (v, keyId) => bindings[keyId] = v);
return bindings;
}

View File

@ -1,7 +1,7 @@
import {MapWrapper} from 'facade/collection';
import {MapWrapper, Map} from 'facade/collection';
import {FIELD, int, isPresent} from 'facade/lang';
var _allKeys = {};
var _allKeys = MapWrapper.create();
var _id:int = 0;
export class Key {
@ -15,8 +15,9 @@ export class Key {
static get(token) {
if (token instanceof Key) return token;
var obj = MapWrapper.get(_allKeys, token);
if (isPresent(obj)) return obj;
if (MapWrapper.contains(_allKeys, token)) {
return MapWrapper.get(_allKeys, token);
}
var newKey = new Key(token, ++_id);
MapWrapper.set(_allKeys, token, newKey);