From 9e3d17b88fea5295804c43243d698cce9b12da58 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Thu, 3 Oct 2019 22:30:55 +0200 Subject: [PATCH] fixup! perf(ivy): move attributes array into component def --- packages/core/src/render3/VIEW_DATA.md | 8 ++++---- packages/core/test/render3/perf/setup.ts | 4 ++-- packages/core/test/render3/render_util.ts | 15 ++++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/core/src/render3/VIEW_DATA.md b/packages/core/src/render3/VIEW_DATA.md index 1fb05e0bb9d2d..0ada819d25ba6 100644 --- a/packages/core/src/render3/VIEW_DATA.md +++ b/packages/core/src/render3/VIEW_DATA.md @@ -14,7 +14,7 @@ The layout is as such: | Section | `LView` | `TView.data` | ---------- | ------------------------------------------------------------ | -------------------------------------------------- | `HEADER` | contextual data | mostly `null` -| `CONSTS` | DOM, pipe, and local ref instances | +| `DECLS` | DOM, pipe, and local ref instances | | `VARS` | binding values | property names | `EXPANDO` | host bindings; directive instances; providers; dynamic nodes | host prop names; directive tokens; provider tokens; `null` @@ -25,10 +25,10 @@ The layout is as such: Mostly information such as parent `LView`, `Sanitizer`, `TView`, and many more bits of information needed for template rendering. -## `CONSTS` +## `DECLS` -`CONSTS` contain the DOM elements, pipe instances, and local refs. -The size of the `CONSTS` section is declared in the property `decls` of the component definition. +`DECLS` contain the DOM elements, pipe instances, and local refs. +The size of the `DECLS` section is declared in the property `decls` of the component definition. ```typescript @Component({ diff --git a/packages/core/test/render3/perf/setup.ts b/packages/core/test/render3/perf/setup.ts index 8b3304425cd0c..a449dc97adcd7 100644 --- a/packages/core/test/render3/perf/setup.ts +++ b/packages/core/test/render3/perf/setup.ts @@ -24,9 +24,9 @@ export function createAndRenderLView( export function setupRootViewWithEmbeddedViews( templateFn: ComponentTemplate| null, decls: number, vars: number, noOfViews: number, - embeddedViewContext: any = {}, attrs: TAttributes[] | null = null): LView { + embeddedViewContext: any = {}, consts: TAttributes[] | null = null): LView { // Create a root view with a container - const rootTView = createTView(-1, null, 1, 0, null, null, null, null, attrs); + const rootTView = createTView(-1, null, 1, 0, null, null, null, null, consts); const tContainerNode = getOrCreateTNode(rootTView, null, 0, TNodeType.Container, null, null); const rootLView = createLView( null, rootTView, {}, LViewFlags.CheckAlways | LViewFlags.IsRoot, null, null, diff --git a/packages/core/test/render3/render_util.ts b/packages/core/test/render3/render_util.ts index e9208b9de1d49..6c802395edd32 100644 --- a/packages/core/test/render3/render_util.ts +++ b/packages/core/test/render3/render_util.ts @@ -103,7 +103,7 @@ export class TemplateFixture extends BaseFixture { private createBlock: () => void, private updateBlock: () => void = noop, decls: number = 0, private vars: number = 0, directives?: DirectiveTypesOrFactory|null, pipes?: PipeTypesOrFactory|null, sanitizer?: Sanitizer|null, - rendererFactory?: RendererFactory3, private _attrs?: TAttributes[]) { + rendererFactory?: RendererFactory3, private _consts?: TAttributes[]) { super(); this._directiveDefs = toDefs(directives, extractDirectiveDef); this._pipeDefs = toDefs(pipes, extractPipeDef); @@ -120,7 +120,7 @@ export class TemplateFixture extends BaseFixture { } }, decls, vars, null !, this._rendererFactory, null, this._directiveDefs, this._pipeDefs, - sanitizer, this._attrs); + sanitizer, this._consts); } /** @@ -132,7 +132,7 @@ export class TemplateFixture extends BaseFixture { renderTemplate( this.hostElement, updateBlock || this.updateBlock, 0, this.vars, null !, this._rendererFactory, this.hostView, this._directiveDefs, this._pipeDefs, this._sanitizer, - this._attrs); + this._consts); } destroy(): void { @@ -243,12 +243,13 @@ export function resetDOM() { * @param host The host element node to use * @param directives Directive defs that should be used for matching * @param pipes Pipe defs that should be used for matching + * @param consts Constants associated with the template. */ export function renderTemplate( hostNode: RElement, templateFn: ComponentTemplate, decls: number, vars: number, context: T, providedRendererFactory: RendererFactory3, componentView: LView | null, directives?: DirectiveDefListOrFactory | null, pipes?: PipeDefListOrFactory | null, - sanitizer?: Sanitizer | null, attrs?: TAttributes[]): LView { + sanitizer?: Sanitizer | null, consts?: TAttributes[]): LView { if (componentView === null) { resetComponentState(); const renderer = providedRendererFactory.createRenderer(null, null); @@ -266,7 +267,7 @@ export function renderTemplate( template: templateFn, decls: decls, vars: vars, - consts: attrs, + consts: consts, }); def.directiveDefs = directives || null; def.pipeDefs = pipes || null; @@ -290,11 +291,11 @@ export function renderToHtml( template: ComponentTemplate, ctx: any, decls: number = 0, vars: number = 0, directives?: DirectiveTypesOrFactory | null, pipes?: PipeTypesOrFactory | null, providedRendererFactory?: RendererFactory3 | null, keepNgReflect = false, - attrs?: TAttributes[]) { + consts?: TAttributes[]) { hostView = renderTemplate( containerEl, template, decls, vars, ctx, providedRendererFactory || testRendererFactory, hostView, toDefs(directives, extractDirectiveDef), toDefs(pipes, extractPipeDef), null, - attrs); + consts); return toHtml(containerEl, keepNgReflect); }