refactor(core): avoid an empty array allocation during hydration (#51917)

This commit updates hydration runtime code to avoid creating an empty array when we can avoid it. Instead, we just check whether the field is `null` directly (without using nullish coalescing).

PR Close #51917
This commit is contained in:
Andrew Kushnir
2023-09-26 15:31:44 -07:00
committed by Dylan Hunn
parent b8f447e611
commit 68648ee684
+2 -2
View File
@@ -67,8 +67,8 @@ let _findMatchingDehydratedViewImpl: typeof findMatchingDehydratedViewImpl =
*/
function findMatchingDehydratedViewImpl(
lContainer: LContainer, template: string|null): DehydratedContainerView|null {
const views = lContainer[DEHYDRATED_VIEWS] ?? [];
if (!template || views.length === 0) {
const views = lContainer[DEHYDRATED_VIEWS];
if (!template || views === null || views.length === 0) {
return null;
}
const view = views[0];