mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-18 09:53:23 +01:00
perf - reduce startup allocations
This commit is contained in:
committed by
Benjamin Pasero
parent
75a7755c65
commit
cd2d361d63
@@ -237,7 +237,7 @@ class MenuInfo {
|
||||
for (const group of this._menuGroups) {
|
||||
const [id, items] = group;
|
||||
|
||||
const activeActions: Array<MenuItemAction | SubmenuItemAction> = [];
|
||||
let activeActions: Array<MenuItemAction | SubmenuItemAction> | undefined;
|
||||
for (const item of items) {
|
||||
if (this._contextKeyService.contextMatchesRules(item.when)) {
|
||||
const isMenuItem = isIMenuItem(item);
|
||||
@@ -249,18 +249,18 @@ class MenuInfo {
|
||||
if (isMenuItem) {
|
||||
// MenuItemAction
|
||||
const menuKeybinding = createConfigureKeybindingAction(item.command.id, item.when, this._commandService, this._keybindingService);
|
||||
activeActions.push(new MenuItemAction(item.command, item.alt, options, menuHide, menuKeybinding, this._contextKeyService, this._commandService));
|
||||
(activeActions ??= []).push(new MenuItemAction(item.command, item.alt, options, menuHide, menuKeybinding, this._contextKeyService, this._commandService));
|
||||
} else {
|
||||
// SubmenuItemAction
|
||||
const groups = new MenuInfo(item.submenu, this._hiddenStates, this._collectContextKeysForSubmenus, this._commandService, this._keybindingService, this._contextKeyService).createActionGroups(options);
|
||||
const submenuActions = Separator.join(...groups.map(g => g[1]));
|
||||
if (submenuActions.length > 0) {
|
||||
activeActions.push(new SubmenuItemAction(item, menuHide, submenuActions));
|
||||
(activeActions ??= []).push(new SubmenuItemAction(item, menuHide, submenuActions));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (activeActions.length > 0) {
|
||||
if (activeActions && activeActions.length > 0) {
|
||||
result.push([id, activeActions]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,13 +292,12 @@ export function applyAvailableEditorIds(contextKey: IContextKey<string>, editor:
|
||||
}
|
||||
|
||||
const editorResource = editor.resource;
|
||||
const editors = editorResource ? editorResolverService.getEditors(editorResource).map(editor => editor.id) : [];
|
||||
|
||||
if (editorResource?.scheme === Schemas.untitled && editor.editorId !== DEFAULT_EDITOR_ASSOCIATION.id) {
|
||||
// Non text editor untitled files cannot be easily serialized between extensions
|
||||
// so instead we disable this context key to prevent common commands that act on the active editor
|
||||
contextKey.set('');
|
||||
} else {
|
||||
const editors = editorResource ? editorResolverService.getEditors(editorResource).map(editor => editor.id) : [];
|
||||
contextKey.set(editors.join(','));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user