From 4452d6d8488280556b89e069df5c7ea2b434dbaf 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 (#33322) PR Close #33322 --- packages/core/src/render3/instructions/shared.ts | 9 +++++---- packages/core/src/render3/interfaces/node.ts | 2 +- .../bundling/cyclic_import/bundle.golden_symbols.json | 6 ------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index d291bb7a4c..c5cd3cde6d 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -1103,6 +1103,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); @@ -1115,8 +1116,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) { @@ -1348,8 +1349,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; diff --git a/packages/core/src/render3/interfaces/node.ts b/packages/core/src/render3/interfaces/node.ts index 352f6eaa6f..1b095bcddd 100644 --- a/packages/core/src/render3/interfaces/node.ts +++ b/packages/core/src/render3/interfaces/node.ts @@ -603,7 +603,7 @@ export interface TProjectionNode extends TNode { } /** - * An union type representing all TNode types that can host a directive. + * A union type representing all TNode types that can host a directive. */ export type TDirectiveHostNode = TElementNode | TContainerNode | TElementContainerNode; diff --git a/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json b/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json index 4ea80638e4..897f619d34 100644 --- a/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json +++ b/packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json @@ -533,12 +533,6 @@ { "name": "objectToClassName" }, - { - "name": "postProcessBaseDirective" - }, - { - "name": "postProcessDirective" - }, { "name": "refreshChildComponents" },