feat: remove MapWrapper.create()/get()/set().

Better dart2js code, better Angular code.
This commit is contained in:
Martin Probst
2015-06-17 16:21:40 -07:00
parent 35e882e74f
commit be7ac9fd41
67 changed files with 388 additions and 418 deletions

View File

@ -89,7 +89,7 @@ export class Injector {
*/
static resolve(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> {
var resolvedBindings = resolveBindings(bindings);
var flatten = _flattenBindings(resolvedBindings, MapWrapper.create());
var flatten = _flattenBindings(resolvedBindings, new Map());
return _createListOfBindings(flatten);
}
@ -389,7 +389,7 @@ export function resolveBindings(bindings: List<Type | Binding | List<any>>): Lis
}
function flattenBindings(bindings: List<ResolvedBinding>): List<ResolvedBinding> {
var map = _flattenBindings(bindings, MapWrapper.create());
var map = _flattenBindings(bindings, new Map());
var res = [];
MapWrapper.forEach(map, (binding, keyId) => res.push(binding));
return res;
@ -406,7 +406,7 @@ function _flattenBindings(bindings: List<ResolvedBinding | List<any>>,
res: Map<number, ResolvedBinding>): Map<number, ResolvedBinding> {
ListWrapper.forEach(bindings, function(b) {
if (b instanceof ResolvedBinding) {
MapWrapper.set(res, b.key.id, b);
res.set(b.key.id, b);
} else if (b instanceof List) {
_flattenBindings(b, res);
}

View File

@ -44,7 +44,7 @@ export class Key {
* @private
*/
export class KeyRegistry {
private _allKeys: Map<Object, Key> = MapWrapper.create();
private _allKeys: Map<Object, Key> = new Map();
get(token: Object): Key {
if (token instanceof Key) return token;
@ -57,11 +57,11 @@ export class KeyRegistry {
token = theToken;
if (MapWrapper.contains(this._allKeys, token)) {
return MapWrapper.get(this._allKeys, token);
return this._allKeys.get(token);
}
var newKey = new Key(token, Key.numberOfKeys);
MapWrapper.set(this._allKeys, token, newKey);
this._allKeys.set(token, newKey);
return newKey;
}