From 68648ee6843d4e2fd5ae14cdf469ab760ff0f16f Mon Sep 17 00:00:00 2001 From: Andrew Kushnir Date: Tue, 26 Sep 2023 15:31:44 -0700 Subject: [PATCH] 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 --- packages/core/src/hydration/views.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/hydration/views.ts b/packages/core/src/hydration/views.ts index 7b033ec7b9c..89191f701e6 100644 --- a/packages/core/src/hydration/views.ts +++ b/packages/core/src/hydration/views.ts @@ -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];