Skip to content

Commit

Permalink
Use Map instead of object map
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jul 2, 2019
1 parent b9edd59 commit a2b1f3e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class StandaloneTheme implements IStandaloneTheme {
public readonly themeName: string;

private readonly themeData: IStandaloneThemeData;
private colors: { [colorId: string]: Color } | null;
private colors: Map<string, Color> | null;
private readonly defaultColors: { [colorId: string]: Color | undefined; };
private _tokenTheme: TokenTheme | null;

Expand Down Expand Up @@ -57,19 +57,18 @@ class StandaloneTheme implements IStandaloneTheme {
}
}

private getColors(): { [colorId: string]: Color } {
private getColors(): Map<string, Color> {
if (!this.colors) {
let colors: { [colorId: string]: Color } = Object.create(null);
const colors = new Map<string, Color>();
for (let id in this.themeData.colors) {
colors[id] = Color.fromHex(this.themeData.colors[id]);
colors.set(id, Color.fromHex(this.themeData.colors[id]));
}
if (this.themeData.inherit) {
let baseData = getBuiltinRules(this.themeData.base);
for (let id in baseData.colors) {
if (!colors[id]) {
colors[id] = Color.fromHex(baseData.colors[id]);
if (!colors.has(id)) {
colors.set(id, Color.fromHex(baseData.colors[id]));
}

}
}
this.colors = colors;
Expand All @@ -78,7 +77,7 @@ class StandaloneTheme implements IStandaloneTheme {
}

public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color | undefined {
const color = this.getColors()[colorId];
const color = this.getColors().get(colorId);
if (color) {
return color;
}
Expand Down

0 comments on commit a2b1f3e

Please sign in to comment.