Skip to content

Commit 88a0af6

Browse files
crisbetothePunderWoman
authored andcommitted
perf(core): generate arrow functions for pure function calls (#51668)
Reworks the pure functions to use arrow functions with an implicit return instead of function expressions. This allows us to shave off some bytes for each pure function, because we can avoid some of the syntax. PR Close #51668
1 parent 8ad21cc commit 88a0af6

13 files changed

Lines changed: 25 additions & 29 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const $c0$ = function () { return { foo: null }; };
2-
const $c1$ = function () { return []; };
3-
const $c2$ = function (a0) { return { foo: a0 }; };
1+
const $c0$ = () => ({ foo: null });
2+
const $c1$ = () => [];
3+
const $c2$ = a0 => ({ foo: a0 });
44
// ...
55
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
66
type: MyApp,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const $c0$ = function () { return []; };
2-
const $c1$ = function () { return [0, 1, 2]; };
1+
const $c0$ = () => [];
2+
const $c1$ = () => [0, 1, 2];
33
// ...
44
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
55
type: MyApp,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const $c0$ = function () { return {}; };
2-
const $c1$ = function () { return { a: 1, b: 2 }; };
1+
const $c0$ = () => ({});
2+
const $c1$ = () => ({ a: 1, b: 2 });
33
// ...
44
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
55
type: MyApp,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const $c0$ = function () { return { foo: null }; };
2-
const $c1$ = function () { return {}; };
3-
const $c2$ = function (a0) { return { foo: a0 }; };
1+
const $c0$ = () => ({ foo: null });
2+
const $c1$ = () => ({});
3+
const $c2$ = a0 => ({ foo: a0 });
44
// ...
55
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
66
type: MyApp,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const $c0$ = function () { return { foo: null }; };
2-
const $c1$ = function (a0) { return { foo: a0 }; };
1+
const $c0$ = () => ({ foo: null });
2+
const $c1$ = a0 => ({ foo: a0 });
33
// ...
44
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
55
type: MyApp,

‎packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_app_def.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const $c0$ = function ($a0$) {
2-
return [$a0$, 1, 2, 3, 4, 5];
3-
};
1+
const $c0$ = $a0$ => [$a0$, 1, 2, 3, 4, 5];
42
// ...
53
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
64
type: MyApp,

‎packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/array_literals.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const $e0_ff$ = function ($v$) { return ["Nancy", $v$]; };
1+
const $e0_ff$ = $v$ => ["Nancy", $v$];
22
// ...
33
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
44
type: MyApp,

‎packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/array_literals_many.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const $e0_ff$ = function ($v0$, $v1$, $v2$, $v3$, $v4$, $v5$, $v6$, $v7$, $v8$) {
2-
return ["start-", $v0$, $v1$, $v2$, $v3$, $v4$, "-middle-", $v5$, $v6$, $v7$, $v8$, "-end"];
3-
}
1+
const $e0_ff$ = ($v0$, $v1$, $v2$, $v3$, $v4$, $v5$, $v6$, $v7$, $v8$) => ["start-", $v0$, $v1$, $v2$, $v3$, $v4$, "-middle-", $v5$, $v6$, $v7$, $v8$, "-end"];
42
// ...
53
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
64
type: MyApp,

‎packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/literal_nested_expression.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const $c0$ = function () { return {opacity: 0, duration: 0}; };
2-
const $e0_ff$ = function ($v$) { return {opacity: 1, duration: $v$}; };
3-
const $e0_ff_1$ = function ($v1$, $v2$) { return [$v1$, $v2$]; };
4-
const $e0_ff_2$ = function ($v1$, $v2$) { return {animation: $v1$, actions: $v2$}; };
1+
const $c0$ = () => ({opacity: 0, duration: 0});
2+
const $e0_ff$ = $v$ => ({opacity: 1, duration: $v$});
3+
const $e0_ff_1$ = ($v1$, $v2$) => [$v1$, $v2$];
4+
const $e0_ff_2$ = ($v1$, $v2$) => ({animation: $v1$, actions: $v2$});
55
// ...
66
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
77
type: MyApp,

‎packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/object_literals.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const $e0_ff$ = function ($v$) { return {"duration": 500, animation: $v$}; };
1+
const $e0_ff$ = $v$ => ({"duration": 500, animation: $v$});
22
// ...
33
MyApp.ɵcmp = /*@__PURE__*/ $r3$.ɵɵdefineComponent({
44
type: MyApp,

0 commit comments

Comments
 (0)