Skip to content

Commit 1b91e10

Browse files
crisbetodylhunn
authored andcommitted
perf(compiler): chain element start/end instructions (#44994)
In templates with several levels of nested nodes, it's common for several `elementStart`/`elementEnd` instructions to show up in a row which can be optimized away. These changes add chaining support for `elementStart`, `elementEnd`, `elementContainerStart` and `elementContainerEnd` to shave off some bytes when possible. PR Close #44994
1 parent 8f1f35b commit 1b91e10

File tree

25 files changed

+67
-69
lines changed

25 files changed

+67
-69
lines changed

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/array_literals_null_vs_empty.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
1010
consts: [[__AttributeMarker.Bindings__, "dir"]],
1111
template: function MyApp_Template(rf, ctx) {
1212
if (rf & 1) {
13-
$r3$.ɵɵelement(0, "div", 0);
14-
$r3$.ɵɵelement(1, "div", 0);
13+
$r3$.ɵɵelement(0, "div", 0)(1, "div", 0);
1514
}
1615
if (rf & 2) {
1716
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction0(2, $c0$));

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/lifecycle_hooks/lifecycle_hooks_simple_layout_def.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ SimpleLayout.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
66
consts: [[__AttributeMarker.Bindings__, "name"]],
77
template: function SimpleLayout_Template(rf, ctx) {
88
if (rf & 1) {
9-
$r3$.ɵɵelement(0, "lifecycle-comp", 0);
10-
$r3$.ɵɵelement(1, "lifecycle-comp", 0);
9+
$r3$.ɵɵelement(0, "lifecycle-comp", 0)(1, "lifecycle-comp", 0);
1110
}
1211
if (rf & 2) {
1312
$r3$.ɵɵproperty("name", ctx.name1);

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/object_literals_null_vs_empty.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
1010
consts: [[__AttributeMarker.Bindings__, "dir"]],
1111
template: function MyApp_Template(rf, ctx) {
1212
if (rf & 1) {
13-
$r3$.ɵɵelement(0, "div", 0);
14-
$r3$.ɵɵelement(1, "div", 0);
13+
$r3$.ɵɵelement(0, "div", 0)(1, "div", 0);
1514
}
1615
if (rf & 2) {
1716
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction0(2, $c0$));

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/object_literals_null_vs_function.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
99
consts: [[__AttributeMarker.Bindings__, "dir"]],
1010
template: function MyApp_Template(rf, ctx) {
1111
if (rf & 1) {
12-
$r3$.ɵɵelement(0, "div", 0);
13-
$r3$.ɵɵelement(1, "div", 0);
12+
$r3$.ɵɵelement(0, "div", 0)(1, "div", 0);
1413
}
1514
if (rf & 2) {
1615
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction0(2, $c0$));

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/template_variables/parent_template_variable.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ function MyComponent_li_1_li_4_Template(rf, ctx) {
1414

1515
function MyComponent_li_1_Template(rf, ctx) {
1616
if (rf & 1) {
17-
$r3$.ɵɵelementStart(0, "li");
18-
$r3$.ɵɵelementStart(1, "div");
17+
$r3$.ɵɵelementStart(0, "li")(1, "div");
1918
$r3$.ɵɵtext(2);
2019
$r3$.ɵɵelementEnd();
2120
$r3$.ɵɵelementStart(3, "ul");
2221
$r3$.ɵɵtemplate(4, MyComponent_li_1_li_4_Template, 2, 2, "li", 0);
23-
$r3$.ɵɵelementEnd();
24-
$r3$.ɵɵelementEnd();
22+
$r3$.ɵɵelementEnd()();
2523
}
2624
if (rf & 2) {
2725
const $item$ = ctx.$implicit;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
consts: [["title", "hi"]],
22
template: function MyComponent_Template(rf, ctx) {
33
if (rf & 1) {
4-
$r3$.ɵɵelement(0, "div", 0);
5-
$r3$.ɵɵelement(1, "span", 0);
4+
$r3$.ɵɵelement(0, "div", 0)(1, "span", 0);
65
}
76
87
}

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/mathml_template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ template: function MyComponent_Template(rf, ctx) {
1010
$r3$.ɵɵnamespaceHTML();
1111
$r3$.ɵɵelementStart(3, "p");
1212
$r3$.ɵɵtext(4, "test");
13-
$r3$.ɵɵelementEnd();
14-
$r3$.ɵɵelementEnd();
13+
$r3$.ɵɵelementEnd()();
1514
}
1615
}

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/security_sensitive_constant_attributes.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ consts: [
66
],
77
template: function MyComponent_Template(rf, ctx) {
88
if (rf & 1) {
9-
$r3$.ɵɵelement(0, "embed", 0);
10-
$r3$.ɵɵelement(1, "iframe", 1);
11-
$r3$.ɵɵelement(2, "object", 2);
12-
$r3$.ɵɵelement(3, "embed", 0);
13-
$r3$.ɵɵelement(4, "img", 3);
9+
$r3$.ɵɵelement(0, "embed", 0)(1, "iframe", 1)(2, "object", 2)(3, "embed", 0)(4, "img", 3);
1410
}
1511
1612
}

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/svg_template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ consts: [["title", "Hello", 1, "my-app"], ["cx", "20", "cy", "30", "r", "50"]],
99
$r3$.ɵɵnamespaceHTML();
1010
$r3$.ɵɵelementStart(3, "p");
1111
$r3$.ɵɵtext(4, "test");
12-
$r3$.ɵɵelementEnd();
13-
$r3$.ɵɵelementEnd();
12+
$r3$.ɵɵelementEnd()();
1413
}
1514
}

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler/nullish_coalescing/nullish_coalescing_property_template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
template: function MyApp_Template(rf, ctx) {
22
if (rf & 1) {
3-
i0.ɵɵelement(0, "div", 0);
4-
i0.ɵɵelement(1, "span", 0);
3+
i0.ɵɵelement(0, "div", 0)(1, "span", 0);
54
}
65
if (rf & 2) {
76
let $tmp_0_0$;

0 commit comments

Comments
 (0)