From 9ce9561737fed57de3772de8c5c7d58afc852d8c Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 14 May 2019 21:45:40 -0700 Subject: [PATCH] perf(ivy): clean up createNodeAtIndex for speed (#30453) PR Close #30453 --- packages/core/src/render3/instructions/shared.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index 869e16e88f..c2667855cf 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -259,9 +259,9 @@ export function createNodeAtIndex( lView[adjustedIndex] = native; const previousOrParentTNode = getPreviousOrParentTNode(); - const isParent = getIsParent(); let tNode = tView.data[adjustedIndex] as TNode; if (tNode == null) { + const isParent = getIsParent(); const parent = isParent ? previousOrParentTNode : previousOrParentTNode && previousOrParentTNode.parent; @@ -282,10 +282,9 @@ export function createNodeAtIndex( previousOrParentTNode.next = tNode; } } - } - - if (tView.firstChild == null) { - tView.firstChild = tNode; + if (index === 0) { + tView.firstChild = tNode; + } } setPreviousOrParentTNode(tNode);