Skip to content

Commit 92fd6cc

Browse files
crisbetoatscott
authored andcommitted
fix(compiler): generate less code for advance instructions (#53845)
We generate `advance` instructions before most update instructions and the majority of `advance` calls are advancing by one. We can save some bytes for the most common case by omitting the parameter for `advance(1)` altogether. PR Close #53845
1 parent c4b266c commit 92fd6cc

File tree

126 files changed

+302
-323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+302
-323
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
1414
}
1515
if (rf & 2) {
1616
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction0(2, $c0$));
17-
$r3$.ɵɵadvance(1);
17+
$r3$.ɵɵadvance();
1818
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction1(4, $c2$, $r3$.ɵɵpureFunction0(3, $c1$)));
1919
}
2020
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ template: function Cmp_Template(rf, ctx) {
2525
}
2626
if (rf & 2) {
2727
$r3$.ɵɵproperty("ngIf", ctx.visible);
28-
$r3$.ɵɵadvance(1);
28+
$r3$.ɵɵadvance();
2929
$r3$.ɵɵproperty("ngIf", ctx.visible);
3030
}
3131
}

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SimpleLayout.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
1010
}
1111
if (rf & 2) {
1212
$r3$.ɵɵproperty("name", ctx.name1);
13-
$r3$.ɵɵadvance(1);
13+
$r3$.ɵɵadvance();
1414
$r3$.ɵɵproperty("name", ctx.name2);
1515
}
1616
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function MyComponent_div_0_span_3_Template(rf, ctx) {
77
if (rf & 2) {
88
const $item$ = $i0$.ɵɵnextContext().$implicit;
99
const $foo$ = $i0$.ɵɵreference(2);
10-
$r3$.ɵɵadvance(1);
10+
$r3$.ɵɵadvance();
1111
$i0$.ɵɵtextInterpolate2(" ", $foo$, " - ", $item$, " ");
1212
}
1313
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ function MyComponent_div_0_span_3_Template(rf, ctx) {
77
if (rf & 2) {
88
const $item$ = $i0$.ɵɵnextContext().$implicit;
99
const $foo$ = $i0$.ɵɵreference(2);
10-
$r3$.ɵɵadvance(1);
10+
$r3$.ɵɵadvance();
1111
$i0$.ɵɵtextInterpolate2(" ", $foo$, " - ", $item$, " ");
1212
}
1313
}
14-
14+
1515
function MyComponent_div_0_Template(rf, ctx) {
1616
if (rf & 1) {
1717
$i0$.ɵɵelementStart(0, "div");
@@ -25,7 +25,7 @@ function MyComponent_div_0_span_3_Template(rf, ctx) {
2525
$i0$.ɵɵproperty("ngIf", $app$.showing);
2626
}
2727
}
28-
28+
2929
// ...
3030
consts: [["foo", ""], [__AttributeMarker.Template__, "ngFor", "ngForOf"], [__AttributeMarker.Template__, "ngIf"]],
3131
template:function MyComponent_Template(rf, ctx){
@@ -36,4 +36,3 @@ function MyComponent_div_0_span_3_Template(rf, ctx) {
3636
$i0$.ɵɵproperty("ngForOf", ctx.items);
3737
}
3838
}
39-

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function MyComponent_div_3_span_2_Template(rf, ctx) {
1010
$r3$.ɵɵnextContext();
1111
const $foo$ = $r3$.ɵɵreference(1);
1212
const $baz$ = $r3$.ɵɵreference(5);
13-
$r3$.ɵɵadvance(1);
13+
$r3$.ɵɵadvance();
1414
$r3$.ɵɵtextInterpolate3("", $foo$, "-", $bar$, "-", $baz$, "");
1515
}
1616
}
@@ -26,7 +26,7 @@ function MyComponent_div_3_span_2_Template(rf, ctx) {
2626
const $bar$ = $r3$.ɵɵreference(4);
2727
$r3$.ɵɵnextContext();
2828
const $foo$ = $r3$.ɵɵreference(1);
29-
$r3$.ɵɵadvance(1);
29+
$r3$.ɵɵadvance();
3030
$r3$.ɵɵtextInterpolate2(" ", $foo$, "-", $bar$, " ");
3131
}
3232
}
@@ -53,4 +53,3 @@ function MyComponent_div_3_span_2_Template(rf, ctx) {
5353
dependencies:[IfDirective],
5454
encapsulation: 2
5555
});
56-

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function MyComponent_div_3_span_2_Template(rf, ctx) {
1010
$r3$.ɵɵnextContext();
1111
const $foo$ = $r3$.ɵɵreference(1);
1212
const $baz$ = $r3$.ɵɵreference(5);
13-
$r3$.ɵɵadvance(1);
13+
$r3$.ɵɵadvance();
1414
$r3$.ɵɵtextInterpolate3("", $foo$, "-", $bar$, "-", $baz$, "");
1515
}
1616
}
@@ -26,7 +26,7 @@ function MyComponent_div_3_Template(rf, ctx) {
2626
const $bar$ = $r3$.ɵɵreference(4);
2727
$r3$.ɵɵnextContext();
2828
const $foo$ = $r3$.ɵɵreference(1);
29-
$r3$.ɵɵadvance(1);
29+
$r3$.ɵɵadvance();
3030
$r3$.ɵɵtextInterpolate2(" ", $foo$, "-", $bar$, " ");
3131
}
3232
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
1414
}
1515
if (rf & 2) {
1616
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction0(2, $c0$));
17-
$r3$.ɵɵadvance(1);
17+
$r3$.ɵɵadvance();
1818
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction1(4, $c2$, $r3$.ɵɵpureFunction0(3, $c1$)));
1919
}
2020
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
1313
}
1414
if (rf & 2) {
1515
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction0(2, $c0$));
16-
$r3$.ɵɵadvance(1);
16+
$r3$.ɵɵadvance();
1717
$r3$.ɵɵproperty("dir", $r3$.ɵɵpureFunction1(3, $c1$, ctx.getFoo()));
1818
}
1919
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function MyComponent_li_1_Template(rf, ctx) {
66
}
77
if (rf & 2) {
88
const $item$ = ctx.$implicit;
9-
$r3$.ɵɵadvance(1);
9+
$r3$.ɵɵadvance();
1010
$r3$.ɵɵtextInterpolate($item$.name);
1111
}
1212
}
@@ -24,7 +24,7 @@ MyComponent.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
2424
$r3$.ɵɵelementEnd();
2525
}
2626
if (rf & 2) {
27-
$r3$.ɵɵadvance(1);
27+
$r3$.ɵɵadvance();
2828
$r3$.ɵɵproperty("forOf", ctx.items);
2929
}
3030
},

0 commit comments

Comments
 (0)