Skip to content

Commit

Permalink
perf(ivy): avoid repeated tNode.initialInputs reads
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource committed Oct 22, 2019
1 parent 2906775 commit 202478b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/render3/instructions/shared.ts
Expand Up @@ -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<any>;
const isComponent = isComponentDef(def);
Expand All @@ -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) {
Expand Down Expand Up @@ -1352,8 +1353,8 @@ export function elementAttributeInternal(
* @param tNode The static data for this node
*/
function setInputsFromAttrs<T>(
lView: LView, directiveIndex: number, instance: T, def: DirectiveDef<T>, tNode: TNode): void {
const initialInputData = tNode.initialInputs as InitialInputData;
lView: LView, directiveIndex: number, instance: T, def: DirectiveDef<T>, tNode: TNode,
initialInputData: InitialInputData): void {
const initialInputs: InitialInputs|null = initialInputData ![directiveIndex];
if (initialInputs !== null) {
const setInput = def.setInput;
Expand Down

0 comments on commit 202478b

Please sign in to comment.