From a2b1f3e77c29ba1fba95906064ff01057de797e6 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 2 Jul 2019 11:33:34 -0700 Subject: [PATCH] Use Map instead of object map #76442 --- .../browser/standaloneThemeServiceImpl.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts b/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts index 5e9074577a3..3f04994e55c 100644 --- a/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts +++ b/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts @@ -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 | null; private readonly defaultColors: { [colorId: string]: Color | undefined; }; private _tokenTheme: TokenTheme | null; @@ -57,19 +57,18 @@ class StandaloneTheme implements IStandaloneTheme { } } - private getColors(): { [colorId: string]: Color } { + private getColors(): Map { if (!this.colors) { - let colors: { [colorId: string]: Color } = Object.create(null); + const colors = new Map(); 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; @@ -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; } -- GitLab