perf - 20% less time spend computing pinned state when many tabs are opened

This commit is contained in:
Benjamin Pasero
2016-12-14 12:10:59 +01:00
parent c980d0821e
commit 1596e0ca10
4 changed files with 23 additions and 4 deletions

View File

@@ -917,6 +917,7 @@ export interface IEditorGroup {
getEditors(mru?: boolean): IEditorInput[];
isActive(editor: IEditorInput): boolean;
isPreview(editor: IEditorInput): boolean;
isPinned(index: number): boolean;
isPinned(editor: IEditorInput): boolean;
}

View File

@@ -482,9 +482,20 @@ export class EditorGroup implements IEditorGroup {
this.closeEditor(oldPreview);
}
public isPinned(editor: EditorInput): boolean {
const index = this.indexOf(editor);
if (index === -1) {
public isPinned(editor: EditorInput): boolean;
public isPinned(index: number): boolean;
public isPinned(arg1: EditorInput | number): boolean {
let editor: EditorInput;
let index: number;
if (typeof arg1 === 'number') {
editor = this.editors[arg1];
index = arg1;
} else {
editor = arg1;
index = this.indexOf(editor);
}
if (index === -1 || !editor) {
return false; // editor not found
}