Skip to content

Commit 612901a

Browse files
committed
Replacing object map with true map
1 parent 4727c9a commit 612901a

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/vs/editor/browser/services/codeEditorServiceImpl.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@ import { ITheme, IThemeService, ThemeColor } from 'vs/platform/theme/common/them
1717
export abstract class CodeEditorServiceImpl extends AbstractCodeEditorService {
1818

1919
private readonly _styleSheet: HTMLStyleElement;
20-
private readonly _decorationOptionProviders: { [key: string]: IModelDecorationOptionsProvider };
20+
private readonly _decorationOptionProviders = new Map<string, IModelDecorationOptionsProvider>();
2121
private readonly _themeService: IThemeService;
2222

2323
constructor(@IThemeService themeService: IThemeService, styleSheet = dom.createStyleSheet()) {
2424
super();
2525
this._styleSheet = styleSheet;
26-
this._decorationOptionProviders = Object.create(null);
2726
this._themeService = themeService;
2827
}
2928

3029
public registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void {
31-
let provider = this._decorationOptionProviders[key];
30+
let provider = this._decorationOptionProviders.get(key);
3231
if (!provider) {
3332
const providerArgs: ProviderArguments = {
3433
styleSheet: this._styleSheet,
@@ -41,25 +40,25 @@ export abstract class CodeEditorServiceImpl extends AbstractCodeEditorService {
4140
} else {
4241
provider = new DecorationSubTypeOptionsProvider(this._themeService, providerArgs);
4342
}
44-
this._decorationOptionProviders[key] = provider;
43+
this._decorationOptionProviders.set(key, provider);
4544
}
4645
provider.refCount++;
4746
}
4847

4948
public removeDecorationType(key: string): void {
50-
const provider = this._decorationOptionProviders[key];
49+
const provider = this._decorationOptionProviders.get(key);
5150
if (provider) {
5251
provider.refCount--;
5352
if (provider.refCount <= 0) {
54-
delete this._decorationOptionProviders[key];
53+
this._decorationOptionProviders.delete(key);
5554
provider.dispose();
5655
this.listCodeEditors().forEach((ed) => ed.removeDecorations(key));
5756
}
5857
}
5958
}
6059

6160
public resolveDecorationOptions(decorationTypeKey: string, writable: boolean): IModelDecorationOptions {
62-
const provider = this._decorationOptionProviders[decorationTypeKey];
61+
const provider = this._decorationOptionProviders.get(decorationTypeKey);
6362
if (!provider) {
6463
throw new Error('Unknown decoration type key: ' + decorationTypeKey);
6564
}

src/vs/editor/contrib/colorPicker/colorDetector.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class ColorDetector extends Disposable implements IEditorContribution {
3636
private _colorDatas = new Map<string, IColorData>();
3737

3838
private _colorDecoratorIds: string[] = [];
39-
private readonly _decorationsTypes: { [key: string]: boolean } = {};
39+
private readonly _decorationsTypes = new Set<string>();
4040

4141
private _isEnabled: boolean;
4242

@@ -180,7 +180,7 @@ export class ColorDetector extends Disposable implements IEditorContribution {
180180
let color = `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
181181
let key = 'colorBox-' + subKey;
182182

183-
if (!this._decorationsTypes[key] && !newDecorationsTypes[key]) {
183+
if (!this._decorationsTypes.has(key) && !newDecorationsTypes[key]) {
184184
this._codeEditorService.registerDecorationType(key, {
185185
before: {
186186
contentText: ' ',
@@ -210,7 +210,7 @@ export class ColorDetector extends Disposable implements IEditorContribution {
210210
});
211211
}
212212

213-
for (let subType in this._decorationsTypes) {
213+
for (const subType of this._decorationsTypes) {
214214
if (!newDecorationsTypes[subType]) {
215215
this._codeEditorService.removeDecorationType(subType);
216216
}
@@ -223,7 +223,7 @@ export class ColorDetector extends Disposable implements IEditorContribution {
223223
this._decorationsIds = this._editor.deltaDecorations(this._decorationsIds, []);
224224
this._colorDecoratorIds = this._editor.deltaDecorations(this._colorDecoratorIds, []);
225225

226-
for (let subType in this._decorationsTypes) {
226+
for (const subType of this._decorationsTypes) {
227227
this._codeEditorService.removeDecorationType(subType);
228228
}
229229
}

0 commit comments

Comments
 (0)