From 202478b96ef5c5f51256f7641c5d8fce918ad77f Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Tue, 22 Oct 2019 16:42:23 +0200 Subject: [PATCH] perf(ivy): avoid repeated tNode.initialInputs reads --- packages/core/src/render3/instructions/shared.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index 661fc98429234a..2a3015658b6dd9 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -1107,6 +1107,7 @@ function instantiateAllDirectives( attachPatchData(native, lView); + const initialInputs = tNode.initialInputs; for (let i = start; i < end; i++) { const def = tView.data[i] as DirectiveDef; const isComponent = isComponentDef(def); @@ -1119,8 +1120,8 @@ function instantiateAllDirectives( const directive = getNodeInjectable(tView.data, lView, i, tNode); attachPatchData(directive, lView); - if (tNode.initialInputs !== null) { - setInputsFromAttrs(lView, i - start, directive, def, tNode); + if (initialInputs !== null) { + setInputsFromAttrs(lView, i - start, directive, def, tNode, initialInputs !); } if (isComponent) { @@ -1352,8 +1353,8 @@ export function elementAttributeInternal( * @param tNode The static data for this node */ function setInputsFromAttrs( - lView: LView, directiveIndex: number, instance: T, def: DirectiveDef, tNode: TNode): void { - const initialInputData = tNode.initialInputs as InitialInputData; + lView: LView, directiveIndex: number, instance: T, def: DirectiveDef, tNode: TNode, + initialInputData: InitialInputData): void { const initialInputs: InitialInputs|null = initialInputData ![directiveIndex]; if (initialInputs !== null) { const setInput = def.setInput;