Skip to content

Commit

Permalink
fixup! perf(ivy): move attributes array into component def
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Oct 3, 2019
1 parent 1c1e7ec commit 9e3d17b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/render3/VIEW_DATA.md
Expand Up @@ -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`

Expand All @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/render3/perf/setup.ts
Expand Up @@ -24,9 +24,9 @@ export function createAndRenderLView(

export function setupRootViewWithEmbeddedViews(
templateFn: ComponentTemplate<any>| 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,
Expand Down
15 changes: 8 additions & 7 deletions packages/core/test/render3/render_util.ts
Expand Up @@ -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);
Expand All @@ -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);
}

/**
Expand All @@ -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 {
Expand Down Expand Up @@ -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<T>(
hostNode: RElement, templateFn: ComponentTemplate<T>, 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);
Expand All @@ -266,7 +267,7 @@ export function renderTemplate<T>(
template: templateFn,
decls: decls,
vars: vars,
consts: attrs,
consts: consts,
});
def.directiveDefs = directives || null;
def.pipeDefs = pipes || null;
Expand All @@ -290,11 +291,11 @@ export function renderToHtml(
template: ComponentTemplate<any>, 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);
}

Expand Down

0 comments on commit 9e3d17b

Please sign in to comment.