refactor(collection): use Map instead of Object
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user