Skip to content

Commit 150dbe4

Browse files
authored
Loop through views less in startup (microsoft#159177)
Probably doesn't save much time (testing showed maybe 1 or 2 ms), but why not.
1 parent 0b5aad3 commit 150dbe4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/vs/workbench/api/browser/viewsExtensionPoint.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { coalesce } from 'vs/base/common/arrays';
76
import { IJSONSchema } from 'vs/base/common/jsonSchema';
87
import * as resources from 'vs/base/common/resources';
98
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
@@ -477,15 +476,18 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
477476
collector.warn(localize('ViewContainerDoesnotExist', "View container '{0}' does not exist and all views registered to it will be added to 'Explorer'.", key));
478477
}
479478
const container = viewContainer || this.getDefaultViewContainer();
480-
const viewDescriptors = coalesce(value.map((item, index) => {
479+
const viewDescriptors: ICustomViewDescriptor[] = [];
480+
481+
for (let index = 0; index < value.length; index++) {
482+
const item = value[index];
481483
// validate
482484
if (viewIds.has(item.id)) {
483485
collector.error(localize('duplicateView1', "Cannot register multiple views with same id `{0}`", item.id));
484-
return null;
486+
continue;
485487
}
486488
if (this.viewsRegistry.getView(item.id) !== null) {
487489
collector.error(localize('duplicateView2', "A view with id `{0}` is already registered.", item.id));
488-
return null;
490+
continue;
489491
}
490492

491493
const order = ExtensionIdentifier.equals(extension.description.identifier, container.extensionId)
@@ -504,7 +506,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
504506
const type = this.getViewType(item.type);
505507
if (!type) {
506508
collector.error(localize('unknownViewType', "Unknown view type `{0}`.", item.type));
507-
return null;
509+
continue;
508510
}
509511

510512
let weight: number | undefined = undefined;
@@ -541,8 +543,8 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
541543

542544

543545
viewIds.add(viewDescriptor.id);
544-
return viewDescriptor;
545-
}));
546+
viewDescriptors.push(viewDescriptor);
547+
}
546548

547549
allViewDescriptors.push({ viewContainer: container, views: viewDescriptors });
548550

0 commit comments

Comments
 (0)