From ad4300f52ba9a7d1cadb3805fc18ae445b968752 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Fri, 15 Nov 2019 15:57:27 +0100 Subject: [PATCH] refactor(ivy): limit reads from TView.consts (#33856) PR Close #33856 --- packages/core/src/render3/instructions/container.ts | 8 +++++--- packages/core/src/render3/instructions/shared.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/src/render3/instructions/container.ts b/packages/core/src/render3/instructions/container.ts index 0b5b9dd704..1e152ac266 100644 --- a/packages/core/src/render3/instructions/container.ts +++ b/packages/core/src/render3/instructions/container.ts @@ -74,10 +74,11 @@ export function ɵɵtemplate( // TODO: consider a separate node type for templates const tContainerNode = containerInternal( lView, index, tagName || null, getConstant(tViewConsts, attrsIndex)); - const localRefs = getConstant(tViewConsts, localRefsIndex); + if (tView.firstCreatePass) { ngDevMode && ngDevMode.firstCreatePass++; - resolveDirectives(tView, lView, tContainerNode, localRefs); + resolveDirectives( + tView, lView, tContainerNode, getConstant(tViewConsts, localRefsIndex)); registerPostOrderHooks(tView, tContainerNode); const embeddedTView = tContainerNode.tViews = createTView( @@ -96,7 +97,8 @@ export function ɵɵtemplate( if (isDirectiveHost(tContainerNode)) { createDirectivesInstances(tView, lView, tContainerNode); } - if (localRefs != null) { + + if (localRefsIndex !== null) { saveResolvedLocalsInData(lView, tContainerNode, localRefExtractor); } diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index 4c38f96096..85ed47b729 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -555,7 +555,7 @@ export function saveResolvedLocalsInData( viewData: LView, tNode: TDirectiveHostNode, localRefExtractor: LocalRefExtractor = getNativeByTNode): void { const localNames = tNode.localNames; - if (localNames) { + if (localNames !== null) { let localIndex = tNode.index + 1; for (let i = 0; i < localNames.length; i += 2) { const index = localNames[i + 1] as number;