debt - use Map instead of object

This commit is contained in:
Johannes Rieken
2016-12-30 15:37:12 +01:00
parent 8385b8c8bc
commit 118b3e0d5a
9 changed files with 110 additions and 117 deletions

View File

@@ -10,20 +10,20 @@ export class ExtHostHeapService extends ExtHostHeapServiceShape {
private static _idPool = 0;
private _data: { [n: number]: any } = Object.create(null);
private _data = new Map<number, any>();
keep(obj: any): number {
const id = ExtHostHeapService._idPool++;
this._data[id] = obj;
this._data.set(id, obj);
return id;
}
delete(id: number): boolean {
return this._data[id];
return this._data.delete(id);
}
get<T>(id: number): T {
return this._data[id];
return this._data.get(id);
}
$onGarbageCollection(ids: number[]): void {
@@ -31,4 +31,4 @@ export class ExtHostHeapService extends ExtHostHeapServiceShape {
this.delete(id);
}
}
}
}