PERF: Improve rendering performance of empty PluginOutlets (#23165)
This commit introduces a 'shortcut' when rendering PluginOutlets which have no registered connectors. On my machine, this improves rendering performance of empty PluginOutlets by around 30-40% (tested by running tachometer on a `/latest` route with 600 plugin outlets).
This commit is contained in:
parent
c48e29db02
commit
121cd886a4
|
@ -22,7 +22,7 @@
|
|||
{{/if}}
|
||||
{{/each}}
|
||||
</this.wrapperComponent>
|
||||
{{else}}
|
||||
{{else if this.connectorsExist}}
|
||||
{{! The modern path: no wrapper element = no classic component }}
|
||||
{{#each this.connectors as |c|}}
|
||||
{{#if c.componentClass}}
|
||||
|
|
|
@ -3,6 +3,7 @@ import ClassicComponent from "@ember/component";
|
|||
|
||||
import {
|
||||
buildArgsWithDeprecations,
|
||||
connectorsExist,
|
||||
renderedConnectorsFor,
|
||||
} from "discourse/lib/plugin-connectors";
|
||||
import { helperContext } from "discourse-common/lib/helpers";
|
||||
|
@ -86,6 +87,10 @@ export default class PluginOutletComponent extends GlimmerComponentWithDeprecate
|
|||
);
|
||||
}
|
||||
|
||||
get connectorsExist() {
|
||||
return connectorsExist(this.args.name);
|
||||
}
|
||||
|
||||
// Traditionally, pluginOutlets had an argument named 'args'. However, that name is reserved
|
||||
// in recent versions of ember so we need to migrate to outletArgs
|
||||
@cached
|
||||
|
|
|
@ -165,6 +165,13 @@ function buildConnectorCache() {
|
|||
}
|
||||
}
|
||||
|
||||
export function connectorsExist(outletName) {
|
||||
if (!_connectorCache) {
|
||||
buildConnectorCache();
|
||||
}
|
||||
return Boolean(_connectorCache[outletName]);
|
||||
}
|
||||
|
||||
export function connectorsFor(outletName) {
|
||||
if (!_connectorCache) {
|
||||
buildConnectorCache();
|
||||
|
|
Loading…
Reference in New Issue