Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(template-compiler): make empty children implicit #2685

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

nolanlawson
Copy link
Collaborator

Details

Fixes #2671

In the template compiler, calls to api_element, api_custom_element, and api_dynamic_element no longer render an empty array ([]) when the children are empty. This removes some boilerplate from generated templates.

I don't expect this to improve runtime performance much (if at all), but the generated code is smaller, so it's definitely more performant from that perspective.

Does this pull request introduce a breaking change?

  • ✅ No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • ✅ No, it does not introduce an observable change.

GUS work item

W-10660536

@nolanlawson
Copy link
Collaborator Author

FWIW, the api_custom_element API already had the EmptyArray default:

// [c]ustom element node
function c(
sel: string,
Ctor: LightningElementConstructor,
data: VElementData,
children: VNodes = EmptyArray
): VCustomElement {

... but it was always being called with the children argument.

@nolanlawson
Copy link
Collaborator Author

Perf tests, just to be sure:

Screen Shot 2022-02-08 at 8 58 04 AM

(100 sample size, 15 min timeout, 1% condition)

I'm going to assume that that 1% is just variance because the test is so short (<100ms).

@nolanlawson nolanlawson merged commit 6795167 into master Feb 8, 2022
@nolanlawson nolanlawson deleted the nolan/empty-children branch February 8, 2022 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Perf] Template compiler should avoid outputting empty children array
2 participants