mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-31 12:16:22 +01:00
Merge pull request #193949 from Connormiha/optimize-flat-map
fix: simplified map+flat
This commit is contained in:
@@ -103,8 +103,7 @@ export class DisposableTracker implements IDisposableTracker {
|
||||
|
||||
const leaking = [...this.livingDisposables.entries()]
|
||||
.filter(([, v]) => v.source !== null && !this.getRootParent(v, rootParentCache).isSingleton)
|
||||
.map(([k]) => k)
|
||||
.flat();
|
||||
.flatMap(([k]) => k);
|
||||
|
||||
return leaking;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ abstract class MainThreadKernel implements INotebookKernel {
|
||||
}
|
||||
|
||||
public get preloadProvides() {
|
||||
return this.preloads.map(p => p.provides).flat();
|
||||
return this.preloads.flatMap(p => p.provides);
|
||||
}
|
||||
|
||||
constructor(data: INotebookKernelDto2, private _languageService: ILanguageService) {
|
||||
|
||||
@@ -52,7 +52,7 @@ class RenameOperation implements IFileOperation {
|
||||
) { }
|
||||
|
||||
get uris() {
|
||||
return this._edits.map(edit => [edit.newUri, edit.oldUri]).flat();
|
||||
return this._edits.flatMap(edit => [edit.newUri, edit.oldUri]);
|
||||
}
|
||||
|
||||
async perform(token: CancellationToken): Promise<IFileOperation> {
|
||||
@@ -106,7 +106,7 @@ class CopyOperation implements IFileOperation {
|
||||
) { }
|
||||
|
||||
get uris() {
|
||||
return this._edits.map(edit => [edit.newUri, edit.oldUri]).flat();
|
||||
return this._edits.flatMap(edit => [edit.newUri, edit.oldUri]);
|
||||
}
|
||||
|
||||
async perform(token: CancellationToken): Promise<IFileOperation> {
|
||||
@@ -297,7 +297,7 @@ class FileUndoRedoElement implements IWorkspaceUndoRedoElement {
|
||||
readonly operations: IFileOperation[],
|
||||
readonly confirmBeforeUndo: boolean
|
||||
) {
|
||||
this.resources = operations.map(op => op.uris).flat();
|
||||
this.resources = operations.flatMap(op => op.uris);
|
||||
}
|
||||
|
||||
async undo(): Promise<void> {
|
||||
|
||||
@@ -81,7 +81,7 @@ export class CodeActionsContribution extends Disposable implements IWorkbenchCon
|
||||
super();
|
||||
|
||||
codeActionsExtensionPoint.setHandler(extensionPoints => {
|
||||
this._contributedCodeActions = extensionPoints.map(x => x.value).flat();
|
||||
this._contributedCodeActions = extensionPoints.flatMap(x => x.value);
|
||||
this.updateConfigurationSchema(this._contributedCodeActions);
|
||||
this._onDidChangeContributions.fire();
|
||||
});
|
||||
@@ -150,7 +150,7 @@ export class CodeActionsContribution extends Disposable implements IWorkbenchCon
|
||||
};
|
||||
|
||||
const getActions = (ofKind: CodeActionKind): ContributedCodeAction[] => {
|
||||
const allActions = this._contributedCodeActions.map(desc => desc.actions).flat();
|
||||
const allActions = this._contributedCodeActions.flatMap(desc => desc.actions);
|
||||
|
||||
const out = new Map<string, ContributedCodeAction>();
|
||||
for (const action of allActions) {
|
||||
|
||||
+1
-2
@@ -91,8 +91,7 @@ export class AiRelatedInformationService implements IAiRelatedInformationService
|
||||
}
|
||||
const result = results
|
||||
.filter(r => r.status === 'fulfilled')
|
||||
.map(r => (r as PromiseFulfilledResult<RelatedInformationResult[]>).value)
|
||||
.flat();
|
||||
.flatMap(r => (r as PromiseFulfilledResult<RelatedInformationResult[]>).value);
|
||||
return result;
|
||||
} finally {
|
||||
stopwatch.stop();
|
||||
|
||||
Reference in New Issue
Block a user