perf(ivy): avoid first template pass checks during view creation (#32120)
PR Close #32120
This commit is contained in:
parent
964d72610f
commit
4c3b791ff3
|
@ -11,14 +11,14 @@ import {attachPatchData} from '../context_discovery';
|
|||
import {executePreOrderHooks, registerPostOrderHooks} from '../hooks';
|
||||
import {ACTIVE_INDEX, CONTAINER_HEADER_OFFSET, LContainer} from '../interfaces/container';
|
||||
import {ComponentTemplate} from '../interfaces/definition';
|
||||
import {LocalRefExtractor, TAttributes, TContainerNode, TNode, TNodeType} from '../interfaces/node';
|
||||
import {LocalRefExtractor, TAttributes, TContainerNode, TNode, TNodeType, TViewNode} from '../interfaces/node';
|
||||
import {BINDING_INDEX, HEADER_OFFSET, LView, RENDERER, TVIEW, T_HOST} from '../interfaces/view';
|
||||
import {assertNodeType} from '../node_assert';
|
||||
import {appendChild, removeView} from '../node_manipulation';
|
||||
import {getCheckNoChangesMode, getIsParent, getLView, getPreviousOrParentTNode, setIsNotParent, setPreviousOrParentTNode} from '../state';
|
||||
import {getNativeByTNode, load} from '../util/view_utils';
|
||||
|
||||
import {addToViewTree, createDirectivesAndLocals, createLContainer, createTView, getOrCreateTNode, resolveDirectives} from './shared';
|
||||
import {addToViewTree, createDirectivesAndLocals, createLContainer, createTNode, createTView, getOrCreateTNode, resolveDirectives} from './shared';
|
||||
|
||||
|
||||
|
||||
|
@ -78,6 +78,10 @@ export function ɵɵtemplate(
|
|||
const embeddedTView = tContainerNode.tViews = createTView(
|
||||
-1, templateFn, consts, vars, tView.directiveRegistry, tView.pipeRegistry, null,
|
||||
tView.schemas);
|
||||
const embeddedTViewNode = createTNode(tView, null, TNodeType.View, -1, null, null) as TViewNode;
|
||||
embeddedTViewNode.injectorIndex = tContainerNode.injectorIndex;
|
||||
embeddedTView.node = embeddedTViewNode;
|
||||
|
||||
if (tView.queries !== null) {
|
||||
tView.queries.template(tView, tContainerNode);
|
||||
embeddedTView.queries = tView.queries.embeddedTView(tContainerNode);
|
||||
|
|
|
@ -304,24 +304,6 @@ export function allocExpando(view: LView, numSlotsToAlloc: number) {
|
|||
//// Render
|
||||
//////////////////////////
|
||||
|
||||
/**
|
||||
* Used for creating the LView of a dynamic embedded view, either through
|
||||
* ViewContainerRef.createEmbeddedView() or TemplateRef.createEmbeddedView().
|
||||
*/
|
||||
export function createEmbeddedViewAndNode<T>(
|
||||
tView: TView, context: T, declarationView: LView, injectorIndex: number): LView {
|
||||
const lView = createLView(declarationView, tView, context, LViewFlags.CheckAlways, null, null);
|
||||
lView[DECLARATION_VIEW] = declarationView;
|
||||
|
||||
assignTViewNodeToLView(tView, null, -1, lView);
|
||||
|
||||
if (tView.firstTemplatePass) {
|
||||
tView.node !.injectorIndex = injectorIndex;
|
||||
}
|
||||
|
||||
return lView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a view in the creation mode. This includes a number of steps in a specific order:
|
||||
* - creating view query functions (if any);
|
||||
|
|
|
@ -106,12 +106,15 @@ export function getNativeByTNode(tNode: TNode, lView: LView): RNode {
|
|||
* @param lView
|
||||
*/
|
||||
export function getNativeByTNodeOrNull(tNode: TNode, lView: LView): RNode|null {
|
||||
ngDevMode && assertTNodeForLView(tNode, lView);
|
||||
const index = tNode.index;
|
||||
const node: RNode|null = index == -1 ? null : unwrapRNode(lView[index]);
|
||||
if (index !== -1) {
|
||||
ngDevMode && assertTNodeForLView(tNode, lView);
|
||||
const node: RNode|null = unwrapRNode(lView[index]);
|
||||
ngDevMode && node !== null && assertDomNode(node);
|
||||
return node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,16 +17,15 @@ import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_Vie
|
|||
import {Renderer2} from '../render/api';
|
||||
import {addToArray, removeFromArray} from '../util/array_utils';
|
||||
import {assertDefined, assertGreaterThan, assertLessThan} from '../util/assert';
|
||||
|
||||
import {assertLContainer} from './assert';
|
||||
import {NodeInjector, getParentInjectorLocation} from './di';
|
||||
import {addToViewTree, createEmbeddedViewAndNode, createLContainer, renderView} from './instructions/shared';
|
||||
import {addToViewTree, createLContainer, createLView, renderView} from './instructions/shared';
|
||||
import {ACTIVE_INDEX, CONTAINER_HEADER_OFFSET, LContainer, VIEW_REFS} from './interfaces/container';
|
||||
import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node';
|
||||
import {RComment, RElement, isProceduralRenderer} from './interfaces/renderer';
|
||||
|
||||
import {isComponent, isLContainer, isLView, isRootView} from './interfaces/type_checks';
|
||||
import {CONTEXT, DECLARATION_LCONTAINER, LView, QUERIES, RENDERER, TView, T_HOST} from './interfaces/view';
|
||||
|
||||
import {CONTEXT, DECLARATION_LCONTAINER, LView, LViewFlags, QUERIES, RENDERER, TView, T_HOST} from './interfaces/view';
|
||||
import {assertNodeOfPossibleTypes} from './node_assert';
|
||||
import {addRemoveViewFromContainer, appendChild, detachView, getBeforeNodeForView, insertView, nativeInsertBefore, nativeNextSibling, nativeParentNode, removeView} from './node_manipulation';
|
||||
import {getParentInjectorTNode} from './node_util';
|
||||
|
@ -108,9 +107,9 @@ export function createTemplateRef<T>(
|
|||
|
||||
createEmbeddedView(context: T): viewEngine_EmbeddedViewRef<T> {
|
||||
const embeddedTView = this._declarationTContainer.tViews as TView;
|
||||
const lView = createEmbeddedViewAndNode(
|
||||
embeddedTView, context, this._declarationView,
|
||||
this._declarationTContainer.injectorIndex);
|
||||
const lView = createLView(
|
||||
this._declarationView, embeddedTView, context, LViewFlags.CheckAlways, null,
|
||||
embeddedTView.node);
|
||||
|
||||
const declarationLContainer = this._declarationView[this._declarationTContainer.index];
|
||||
ngDevMode && assertLContainer(declarationLContainer);
|
||||
|
|
|
@ -470,9 +470,6 @@
|
|||
{
|
||||
"name": "assertTemplate"
|
||||
},
|
||||
{
|
||||
"name": "assignTViewNodeToLView"
|
||||
},
|
||||
{
|
||||
"name": "attachPatchData"
|
||||
},
|
||||
|
@ -536,9 +533,6 @@
|
|||
{
|
||||
"name": "createElementRef"
|
||||
},
|
||||
{
|
||||
"name": "createEmbeddedViewAndNode"
|
||||
},
|
||||
{
|
||||
"name": "createLContainer"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue