perf(ivy): remove repeated memory read / write in addComponentLogic (#32339)

PR Close #32339
This commit is contained in:
Pawel Kozlowski 2019-08-27 12:02:30 +02:00 committed by Miško Hevery
parent 60a056d5dc
commit 581b837e88
1 changed files with 5 additions and 7 deletions

View File

@ -1321,19 +1321,17 @@ function baseResolveDirective<T>(tView: TView, viewData: LView, def: DirectiveDe
} }
function addComponentLogic<T>(lView: LView, hostTNode: TNode, def: ComponentDef<T>): void { function addComponentLogic<T>(lView: LView, hostTNode: TNode, def: ComponentDef<T>): void {
const native = getNativeByTNode(hostTNode, lView); const native = getNativeByTNode(hostTNode, lView) as RElement;
const tView = getOrCreateTView(def); const tView = getOrCreateTView(def);
// Only component views should be added to the view tree directly. Embedded views are // Only component views should be added to the view tree directly. Embedded views are
// accessed through their containers because they may be removed / re-added later. // accessed through their containers because they may be removed / re-added later.
const rendererFactory = lView[RENDERER_FACTORY]; const rendererFactory = lView[RENDERER_FACTORY];
const componentView = addToViewTree( const componentView = addToViewTree(
lView, createLView( lView,
lView, tView, null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways, createLView(
lView[hostTNode.index], hostTNode as TElementNode, rendererFactory, lView, tView, null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways, native,
rendererFactory.createRenderer(native as RElement, def))); hostTNode as TElementNode, rendererFactory, rendererFactory.createRenderer(native, def)));
componentView[T_HOST] = hostTNode as TElementNode;
// Component view will always be created before any injected LContainers, // Component view will always be created before any injected LContainers,
// so this is a regular element, wrap it with the component view // so this is a regular element, wrap it with the component view