@samitouri / QOS-React-1 / commits / 28767a7afb

Inline reactive scope dep checks; no more change vars

Reactive scopes are currently preceded by individual variable declarations, one for each of the scope's dependencies. Only after checking independently if each of these dependencies has changed do we then do an "or" to check if we should actually recompute the body of the scope. But that's wasteful: it's more efficient to rely on `||` short-circuiting, and recompute as soon as any input changes. The main reason I can see not to do this is debugging. Having the change variables makes it easy to see what changed. But at this point I think it makes sense to optimize for code size and performance; we can always add back a dev-only mode that uses change variables if that turns out to help debugging.

Joe Savona committed Oct 12, 2023 at 12:03 UTC 28767a7afb7ca426712b588dbc3beacc12f645b8
330 files changed +554 -1262
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+8 -19
@@ -237,28 +237,17 @@ function codegenMemoBlockForReactiveScope(
237 ): void {
238 const cacheStoreStatements: Array<t.Statement> = [];
239 const cacheLoadStatements: Array<t.Statement> = [];
240 - const changeIdentifiers: Array<t.Identifier> = [];
240 + const changeExpressions: Array<t.Expression> = [];
241 for (const dep of scope.dependencies) {
242 const index = cx.nextCacheIndex;
243 - const changeIdentifier = t.identifier(`c_${index}`);
243 const depValue = codegenDependency(cx, dep);
244
246 - changeIdentifiers.push(changeIdentifier);
247 - statements.push(
248 - t.variableDeclaration("const", [
249 - t.variableDeclarator(
250 - changeIdentifier,
251 - t.binaryExpression(
252 - "!==",
253 - t.memberExpression(
254 - t.identifier("$"),
255 - t.numericLiteral(index),
256 - true
257 - ),
258 - depValue
259 - )
260 - ),
261 - ])
245 + changeExpressions.push(
246 + t.binaryExpression(
247 + "!==",
248 + t.memberExpression(t.identifier("$"), t.numericLiteral(index), true),
249 + depValue
250 + )
251 );
252 cacheStoreStatements.push(
253 t.expressionStatement(
@@ -336,7 +325,7 @@ function codegenMemoBlockForReactiveScope(
325 )
326 );
327 }
339 - let testCondition = (changeIdentifiers as Array<t.Expression>).reduce(
328 + let testCondition = (changeExpressions as Array<t.Expression>).reduce(
329 (acc: t.Expression | null, ident: t.Expression) => {
330 if (acc == null) {
331 return ident;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/alias-computed-load.expect.md
+1 -2
@@ -19,9 +19,8 @@ function component(a) {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function component(a) {
21 const $ = useMemoCache(2);
22 - const c_0 = $[0] !== a;
22 let x;
24 - if (c_0) {
23 + if ($[0] !== a) {
24 x = { a };
25 const y = {};
26
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/alias-while.expect.md
+1 -2
@@ -29,9 +29,8 @@ function mutate(x, y) {}
29 import { unstable_useMemoCache as useMemoCache } from "react";
30 function foo(cond) {
31 const $ = useMemoCache(2);
32 - const c_0 = $[0] !== cond;
32 let a;
34 - if (c_0) {
33 + if ($[0] !== cond) {
34 a = {};
35 let b = {};
36 let c = {};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md
+3 -8
@@ -25,17 +25,14 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // bar(props.b) i
25 // - y depends on either bar(props.b) or bar(props.b) + 1
26 function AllocatingPrimitiveAsDepNested(props) {
27 const $ = useMemoCache(9);
28 - const c_0 = $[0] !== props.b;
29 - const c_1 = $[1] !== props.a;
28 let x;
29 let y;
32 - if (c_0 || c_1) {
30 + if ($[0] !== props.b || $[1] !== props.a) {
31 x = {};
32 mutate(x);
33 const t0 = bar(props.b) + 1;
36 - const c_4 = $[4] !== t0;
34 let t1;
38 - if (c_4) {
35 + if ($[4] !== t0) {
36 t1 = foo(t0);
37 $[4] = t0;
38 $[5] = t1;
@@ -52,10 +49,8 @@ function AllocatingPrimitiveAsDepNested(props) {
49 x = $[2];
50 y = $[3];
51 }
55 - const c_6 = $[6] !== x;
56 - const c_7 = $[7] !== y;
52 let t2;
58 - if (c_6 || c_7) {
53 + if ($[6] !== x || $[7] !== y) {
54 t2 = [x, y];
55 $[6] = x;
56 $[7] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep.expect.md
+1 -2
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // bar(props.b) i
23 function AllocatingPrimitiveAsDep(props) {
24 const $ = useMemoCache(2);
25 const t0 = bar(props).b + 1;
26 - const c_0 = $[0] !== t0;
26 let t1;
28 - if (c_0) {
27 + if ($[0] !== t0) {
28 t1 = foo(t0);
29 $[0] = t0;
30 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allow-passing-refs-as-props.expect.md
+1 -2
@@ -16,9 +16,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(2);
18 const ref = useRef(null);
19 - const c_0 = $[0] !== ref;
19 let t0;
21 - if (c_0) {
20 + if ($[0] !== ref) {
21 t0 = <Foo ref={ref} />;
22 $[0] = ref;
23 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md
+3 -9
@@ -25,16 +25,12 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function foo(a, b, c) {
27 const $ = useMemoCache(10);
28 - const c_0 = $[0] !== a;
29 - const c_1 = $[1] !== b;
30 - const c_2 = $[2] !== c;
28 let x;
29 let z;
33 - if (c_0 || c_1 || c_2) {
30 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
31 x = [a];
35 - const c_5 = $[5] !== b;
32 let t0;
37 - if (c_5) {
33 + if ($[5] !== b) {
34 t0 = [null, b];
35 $[5] = b;
36 $[6] = t0;
@@ -54,10 +50,8 @@ function foo(a, b, c) {
50 x = $[3];
51 z = $[4];
52 }
57 - const c_7 = $[7] !== x;
58 - const c_8 = $[8] !== z;
53 let t1;
60 - if (c_7 || c_8) {
54 + if ($[7] !== x || $[8] !== z) {
55 t1 = [x, z];
56 $[7] = x;
57 $[8] = z;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md
+3 -7
@@ -20,9 +20,8 @@ function Component(props) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(7);
23 - const c_0 = $[0] !== props.x;
23 let t0;
25 - if (c_0) {
24 + if ($[0] !== props.x) {
25 t0 = foo(props.x);
26 $[0] = props.x;
27 $[1] = t0;
@@ -30,10 +29,8 @@ function Component(props) {
29 t0 = $[1];
30 }
31 const x = t0;
33 - const c_2 = $[2] !== props;
34 - const c_3 = $[3] !== x;
32 let t1;
36 - if (c_2 || c_3) {
33 + if ($[2] !== props || $[3] !== x) {
34 t1 = function () {
35 const arr = [...bar(props)];
36 return arr.at(x);
@@ -45,9 +42,8 @@ function Component(props) {
42 t1 = $[4];
43 }
44 const fn = t1;
48 - const c_5 = $[5] !== fn;
45 let t2;
50 - if (c_5) {
46 + if ($[5] !== fn) {
47 t2 = fn();
48 $[5] = fn;
49 $[6] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md
+4 -9
@@ -23,18 +23,16 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // arrayInstance.
23 // - mutate on lvalue
24 function ArrayAtTest(props) {
25 const $ = useMemoCache(9);
26 - const c_0 = $[0] !== props.x;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== props.x) {
28 t0 = foo(props.x);
29 $[0] = props.x;
30 $[1] = t0;
31 } else {
32 t0 = $[1];
33 }
35 - const c_2 = $[2] !== t0;
34 let t1;
37 - if (c_2) {
35 + if ($[2] !== t0) {
36 t1 = [t0];
37 $[2] = t0;
38 $[3] = t1;
@@ -42,13 +40,10 @@ function ArrayAtTest(props) {
40 t1 = $[3];
41 }
42 const arr = t1;
45 - const c_4 = $[4] !== props.y;
46 - const c_5 = $[5] !== arr;
43 let t3;
48 - if (c_4 || c_5) {
49 - const c_7 = $[7] !== props.y;
44 + if ($[4] !== props.y || $[5] !== arr) {
45 let t2;
51 - if (c_7) {
46 + if ($[7] !== props.y) {
47 t2 = bar(props.y);
48 $[7] = props.y;
49 $[8] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-expression-spread.expect.md
+1 -3
@@ -21,10 +21,8 @@ export const FIXTURE_ENTRYPOINT = {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(3);
24 - const c_0 = $[0] !== props.foo;
25 - const c_1 = $[1] !== props.bar;
24 let t0;
27 - if (c_0 || c_1) {
25 + if ($[0] !== props.foo || $[1] !== props.bar) {
26 t0 = [0, ...props.foo, null, ...props.bar, "z"];
27 $[0] = props.foo;
28 $[1] = props.bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-join.expect.md
+2 -5
@@ -28,9 +28,8 @@ function Component(props) {
28 t0 = $[0];
29 t1 = $[1];
30 }
31 - const c_2 = $[2] !== props.value;
31 let t2;
33 - if (c_2) {
32 + if ($[2] !== props.value) {
33 t2 = [t0, t1, props.value];
34 $[2] = props.value;
35 $[3] = t2;
@@ -47,10 +46,8 @@ function Component(props) {
46 }
47 const y = x.join(t3);
48 foo(y);
50 - const c_5 = $[5] !== x;
51 - const c_6 = $[6] !== y;
49 let t4;
53 - if (c_5 || c_6) {
50 + if ($[5] !== x || $[6] !== y) {
51 t4 = [x, y];
52 $[5] = x;
53 $[6] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.expect.md
+1 -2
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== props.a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== props.a) {
29 const item = { a: props.a };
30 const items = [item];
31 t0 = items.map((item_0) => item_0);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.expect.md
+2 -4
@@ -30,9 +30,8 @@ function Component(props) {
30 t0 = $[0];
31 }
32 const f = t0;
33 - const c_1 = $[1] !== props.items;
33 let t1;
35 - if (c_1) {
34 + if ($[1] !== props.items) {
35 t1 = [...props.items].map(f);
36 $[1] = props.items;
37 $[2] = t1;
@@ -40,9 +39,8 @@ function Component(props) {
39 t1 = $[2];
40 }
41 const x = t1;
43 - const c_3 = $[3] !== x;
42 let t2;
45 - if (c_3) {
43 + if ($[3] !== x) {
44 t2 = [x, f];
45 $[3] = x;
46 $[4] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md
+3 -7
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
23 function component(t16) {
24 const $ = useMemoCache(7);
25 const [a, b] = t16;
26 - const c_0 = $[0] !== a;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 t0 = { a };
29 $[0] = a;
30 $[1] = t0;
@@ -33,9 +32,8 @@ function component(t16) {
32 t0 = $[1];
33 }
34 const y = t0;
36 - const c_2 = $[2] !== b;
35 let t1;
38 - if (c_2) {
36 + if ($[2] !== b) {
37 t1 = { b };
38 $[2] = b;
39 $[3] = t1;
@@ -43,10 +41,8 @@ function component(t16) {
41 t1 = $[3];
42 }
43 const z = t1;
46 - const c_4 = $[4] !== y;
47 - const c_5 = $[5] !== z;
44 let t2;
49 - if (c_4 || c_5) {
45 + if ($[4] !== y || $[5] !== z) {
46 t2 = [y, z];
47 $[4] = y;
48 $[5] = z;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-properties.expect.md
+2 -7
@@ -23,10 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(7);
26 - const c_0 = $[0] !== props.a;
27 - const c_1 = $[1] !== props.b;
26 let t0;
29 - if (c_0 || c_1) {
27 + if ($[0] !== props.a || $[1] !== props.b) {
28 t0 = [props.a, props.b, "hello"];
29 $[0] = props.a;
30 $[1] = props.b;
@@ -37,11 +35,8 @@ function Component(props) {
35 const a = t0;
36 const x = a.length;
37 const y = a.push;
40 - const c_3 = $[3] !== a;
41 - const c_4 = $[4] !== x;
42 - const c_5 = $[5] !== y;
38 let t1;
44 - if (c_3 || c_4 || c_5) {
39 + if ($[3] !== a || $[4] !== x || $[5] !== y) {
40 t1 = { a, x, y, z: a.concat };
41 $[3] = a;
42 $[4] = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-property-call.expect.md
+3 -10
@@ -24,11 +24,9 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(11);
27 - const c_0 = $[0] !== props.a;
28 - const c_1 = $[1] !== props.b;
27 let t0;
28 let a;
31 - if (c_0 || c_1) {
29 + if ($[0] !== props.a || $[1] !== props.b) {
30 a = [props.a, props.b, "hello"];
31 t0 = a.push(42);
32 $[0] = props.a;
@@ -40,10 +38,8 @@ function Component(props) {
38 a = $[3];
39 }
40 const x = t0;
43 - const c_4 = $[4] !== a;
44 - const c_5 = $[5] !== props.c;
41 let t1;
46 - if (c_4 || c_5) {
42 + if ($[4] !== a || $[5] !== props.c) {
43 t1 = a.at(props.c);
44 $[4] = a;
45 $[5] = props.c;
@@ -52,11 +48,8 @@ function Component(props) {
48 t1 = $[6];
49 }
50 const y = t1;
55 - const c_7 = $[7] !== a;
56 - const c_8 = $[8] !== x;
57 - const c_9 = $[9] !== y;
51 let t2;
59 - if (c_7 || c_8 || c_9) {
52 + if ($[7] !== a || $[8] !== x || $[9] !== y) {
53 t2 = { a, x, y };
54 $[7] = a;
55 $[8] = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-push-effect.expect.md
+3 -7
@@ -24,9 +24,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // arrayInstance.
24 // - mutate on receiver
25 function Component(props) {
26 const $ = useMemoCache(8);
27 - const c_0 = $[0] !== props.x;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== props.x) {
29 t0 = foo(props.x);
30 $[0] = props.x;
31 $[1] = t0;
@@ -34,9 +33,8 @@ function Component(props) {
33 t0 = $[1];
34 }
35 const x = t0;
37 - const c_2 = $[2] !== props.y;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== props.y) {
38 t1 = { y: props.y };
39 $[2] = props.y;
40 $[3] = t1;
@@ -44,10 +42,8 @@ function Component(props) {
42 t1 = $[3];
43 }
44 const y = t1;
47 - const c_4 = $[4] !== x;
48 - const c_5 = $[5] !== y;
45 let arr;
50 - if (c_4 || c_5) {
46 + if ($[4] !== x || $[5] !== y) {
47 arr = [];
48 let t2;
49 if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md
+1 -2
@@ -17,9 +17,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
17 const ErrorView = isForgetEnabled_Fixtures()
18 ? (error, _retry) => {
19 const $ = useMemoCache(2);
20 - const c_0 = $[0] !== error;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== error) {
22 t0 = <MessageBox error={error} />;
23 $[0] = error;
24 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/assignment-expression-computed.expect.md
+1 -2
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== props.x;
27 let x;
29 - if (c_0) {
28 + if ($[0] !== props.x) {
29 x = [props.x];
30
31 x[0] = x[0] * 2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/assignment-expression-nested-path.expect.md
+1 -2
@@ -23,9 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function g(props) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== props.c;
26 let a;
28 - if (c_0) {
27 + if ($[0] !== props.c) {
28 a = { b: { c: props.c } };
29 a.b.c = a.b.c + 1;
30 a.b.c = a.b.c * 2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/await-side-effecting-promise.expect.md
+1 -2
@@ -16,9 +16,8 @@ async function Component(props) {
16 import { unstable_useMemoCache as useMemoCache } from "react";
17 async function Component(props) {
18 const $ = useMemoCache(2);
19 - const c_0 = $[0] !== props.id;
19 let x;
21 - if (c_0) {
20 + if ($[0] !== props.id) {
21 x = [];
22 await populateData(props.id, x);
23 $[0] = props.id;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/await.expect.md
+2 -4
@@ -15,9 +15,8 @@ async function Component(props) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 async function Component(props) {
17 const $ = useMemoCache(4);
18 - const c_0 = $[0] !== props.id;
18 let t0;
20 - if (c_0) {
19 + if ($[0] !== props.id) {
20 t0 = await load(props.id);
21 $[0] = props.id;
22 $[1] = t0;
@@ -25,9 +24,8 @@ async function Component(props) {
24 t0 = $[1];
25 }
26 const user = t0;
28 - const c_2 = $[2] !== user.name;
27 let t1;
30 - if (c_2) {
28 + if ($[2] !== user.name) {
29 t1 = <div>{user.name}</div>;
30 $[2] = user.name;
31 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md
+4 -8
@@ -33,9 +33,8 @@ function Component(props) {
33 const $ = useMemoCache(4);
34 const [x] = useState(0);
35 let t35;
36 - const c_0 = $[0] !== x;
36 let t0;
38 - if (c_0) {
37 + if ($[0] !== x) {
38 t0 = calculateExpensiveNumber(x);
39 $[0] = x;
40 $[1] = t0;
@@ -44,9 +43,8 @@ function Component(props) {
43 }
44 t35 = t0;
45 const expensiveNumber = t35;
47 - const c_2 = $[2] !== expensiveNumber;
46 let t1;
49 - if (c_2) {
47 + if ($[2] !== expensiveNumber) {
48 t1 = <div>{expensiveNumber}</div>;
49 $[2] = expensiveNumber;
50 $[3] = t1;
@@ -60,9 +58,8 @@ function Component2(props) {
58 const $ = useMemoCache(4);
59 const [x] = useState(0);
60 let t35;
63 - const c_0 = $[0] !== x;
61 let t0;
65 - if (c_0) {
62 + if ($[0] !== x) {
63 t0 = calculateExpensiveNumber(x);
64 $[0] = x;
65 $[1] = t0;
@@ -71,9 +68,8 @@ function Component2(props) {
68 }
69 t35 = t0;
70 const expensiveNumber = t35;
74 - const c_2 = $[2] !== expensiveNumber;
71 let t1;
76 - if (c_2) {
72 + if ($[2] !== expensiveNumber) {
73 t1 = <div>{expensiveNumber}</div>;
74 $[2] = expensiveNumber;
75 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-kitchensink-import.expect.md
+4 -8
@@ -35,9 +35,8 @@ function Component(props) {
35 const $ = useMemoCache(4);
36 const [x] = useState(0);
37 let t35;
38 - const c_0 = $[0] !== x;
38 let t0;
40 - if (c_0) {
39 + if ($[0] !== x) {
40 t0 = calculateExpensiveNumber(x);
41 $[0] = x;
42 $[1] = t0;
@@ -46,9 +45,8 @@ function Component(props) {
45 }
46 t35 = t0;
47 const expensiveNumber = t35;
49 - const c_2 = $[2] !== expensiveNumber;
48 let t1;
51 - if (c_2) {
49 + if ($[2] !== expensiveNumber) {
50 t1 = <div>{expensiveNumber}</div>;
51 $[2] = expensiveNumber;
52 $[3] = t1;
@@ -62,9 +60,8 @@ function Component2(props) {
60 const $ = useMemoCache(4);
61 const [x] = useState(0);
62 let t35;
65 - const c_0 = $[0] !== x;
63 let t0;
67 - if (c_0) {
64 + if ($[0] !== x) {
65 t0 = calculateExpensiveNumber(x);
66 $[0] = x;
67 $[1] = t0;
@@ -73,9 +70,8 @@ function Component2(props) {
70 }
71 t35 = t0;
72 const expensiveNumber = t35;
76 - const c_2 = $[2] !== expensiveNumber;
73 let t1;
78 - if (c_2) {
74 + if ($[2] !== expensiveNumber) {
75 t1 = <div>{expensiveNumber}</div>;
76 $[2] = expensiveNumber;
77 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md
+1 -2
@@ -32,9 +32,8 @@ function Component(props) {
32 let t39;
33 t39 = calculateExpensiveNumber(x);
34 const expensiveNumber = t39;
35 - const c_0 = $[0] !== expensiveNumber;
35 let t0;
37 - if (c_0) {
36 + if ($[0] !== expensiveNumber) {
37 t0 = <div>{expensiveNumber}</div>;
38 $[0] = expensiveNumber;
39 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md
+1 -2
@@ -30,9 +30,8 @@ function App(t23) {
30
31 hasDeps ? null : [text];
32 let t44;
33 - const c_0 = $[0] !== text;
33 let t0;
35 - if (c_0) {
34 + if ($[0] !== text) {
35 t0 = text.toUpperCase();
36 $[0] = text;
37 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug_object-pattern.expect.md
+1 -2
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
23 function component(t) {
24 const $ = useMemoCache(2);
25 const { a } = t;
26 - const c_0 = $[0] !== a;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 t0 = { a };
29 $[0] = a;
30 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-spread.expect.md
+1 -3
@@ -15,10 +15,8 @@ function Component(props) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(3);
18 - const c_0 = $[0] !== props.a;
19 - const c_1 = $[1] !== props.b;
18 let t0;
21 - if (c_0 || c_1) {
19 + if ($[0] !== props.a || $[1] !== props.b) {
20 t0 = foo(...props.a, null, ...props.b);
21 $[0] = props.a;
22 $[1] = props.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md
+2 -4
@@ -20,13 +20,11 @@ function Component(props) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(4);
23 - const c_0 = $[0] !== props;
23 let t1;
25 - if (c_0) {
24 + if ($[0] !== props) {
25 const x = makeFunction(props);
27 - const c_2 = $[2] !== props.text;
26 let t0;
29 - if (c_2) {
27 + if ($[2] !== props.text) {
28 t0 = (
29 <div>
30 <span>{props.text}</span>
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias-iife.expect.md
+1 -2
@@ -28,9 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function component(a) {
30 const $ = useMemoCache(2);
31 - const c_0 = $[0] !== a;
31 let x;
33 - if (c_0) {
32 + if ($[0] !== a) {
33 x = { a };
34
35 const q = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias.expect.md
+1 -2
@@ -30,9 +30,8 @@ export const FIXTURE_ENTRYPOINT = {
30 import { unstable_useMemoCache as useMemoCache } from "react";
31 function component(a) {
32 const $ = useMemoCache(2);
33 - const c_0 = $[0] !== a;
33 let x;
35 - if (c_0) {
34 + if ($[0] !== a) {
35 x = { a };
36 const f0 = function () {
37 const q = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capture-param-mutate.expect.md
+1 -2
@@ -48,9 +48,8 @@ function getNativeLogFunction(level) {
48 import { unstable_useMemoCache as useMemoCache } from "react";
49 function getNativeLogFunction(level) {
50 const $ = useMemoCache(2);
51 - const c_0 = $[0] !== level;
51 let t0;
53 - if (c_0) {
52 + if ($[0] !== level) {
53 t0 = function () {
54 let str = undefined;
55 if (arguments.length === 1 && typeof arguments[0] === "string") {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns-iife.expect.md
+1 -2
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function component(a) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== a;
29 let z;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 z = { a };
32
33 (function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns.expect.md
+1 -2
@@ -28,9 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function component(a) {
30 const $ = useMemoCache(2);
31 - const c_0 = $[0] !== a;
31 let z;
33 - if (c_0) {
32 + if ($[0] !== a) {
33 z = { a };
34 const f0 = function () {
35 const f1 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-arrow-function-1.expect.md
+2 -4
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function component(a) {
26 const $ = useMemoCache(4);
27 - const c_0 = $[0] !== a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 t0 = { a };
30 $[0] = a;
31 $[1] = t0;
@@ -34,9 +33,8 @@ function component(a) {
33 t0 = $[1];
34 }
35 const z = t0;
37 - const c_2 = $[2] !== z;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== z) {
38 t1 = () => {
39 console.log(z);
40 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2-iife.expect.md
+1 -3
@@ -31,10 +31,8 @@ import { mutate } from "shared-runtime";
31
32 function component(foo, bar) {
33 const $ = useMemoCache(3);
34 - const c_0 = $[0] !== foo;
35 - const c_1 = $[1] !== bar;
34 let x;
37 - if (c_0 || c_1) {
35 + if ($[0] !== foo || $[1] !== bar) {
36 x = { foo };
37 const y = { bar };
38
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md
+1 -3
@@ -23,10 +23,8 @@ function component(foo, bar) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function component(foo, bar) {
25 const $ = useMemoCache(3);
26 - const c_0 = $[0] !== foo;
27 - const c_1 = $[1] !== bar;
26 let x;
29 - if (c_0 || c_1) {
27 + if ($[0] !== foo || $[1] !== bar) {
28 x = { foo };
29 const y = { bar };
30 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2-iife.expect.md
+1 -3
@@ -31,10 +31,8 @@ const { mutate } = require("shared-runtime");
31
32 function component(foo, bar) {
33 const $ = useMemoCache(3);
34 - const c_0 = $[0] !== foo;
35 - const c_1 = $[1] !== bar;
34 let x;
37 - if (c_0 || c_1) {
35 + if ($[0] !== foo || $[1] !== bar) {
36 x = { foo };
37 const y = { bar };
38
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md
+1 -3
@@ -23,10 +23,8 @@ function component(foo, bar) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function component(foo, bar) {
25 const $ = useMemoCache(3);
26 - const c_0 = $[0] !== foo;
27 - const c_1 = $[1] !== bar;
26 let x;
29 - if (c_0 || c_1) {
27 + if ($[0] !== foo || $[1] !== bar) {
28 x = { foo };
29 const y = { bar };
30 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr-iife.expect.md
+1 -3
@@ -31,10 +31,8 @@ const { mutate } = require("shared-runtime");
31
32 function component(foo, bar) {
33 const $ = useMemoCache(3);
34 - const c_0 = $[0] !== foo;
35 - const c_1 = $[1] !== bar;
34 let y;
37 - if (c_0 || c_1) {
35 + if ($[0] !== foo || $[1] !== bar) {
36 const x = { foo };
37 y = { bar };
38
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md
+1 -3
@@ -23,10 +23,8 @@ function component(foo, bar) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function component(foo, bar) {
25 const $ = useMemoCache(3);
26 - const c_0 = $[0] !== foo;
27 - const c_1 = $[1] !== bar;
26 let y;
29 - if (c_0 || c_1) {
27 + if ($[0] !== foo || $[1] !== bar) {
28 const x = { foo };
29 y = { bar };
30 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-iife.expect.md
+1 -3
@@ -31,10 +31,8 @@ const { mutate } = require("shared-runtime");
31
32 function component(foo, bar) {
33 const $ = useMemoCache(3);
34 - const c_0 = $[0] !== foo;
35 - const c_1 = $[1] !== bar;
34 let y;
37 - if (c_0 || c_1) {
35 + if ($[0] !== foo || $[1] !== bar) {
36 const x = { foo };
37 y = { bar };
38
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate.expect.md
+1 -3
@@ -23,10 +23,8 @@ function component(foo, bar) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function component(foo, bar) {
25 const $ = useMemoCache(3);
26 - const c_0 = $[0] !== foo;
27 - const c_1 = $[1] !== bar;
26 let y;
29 - if (c_0 || c_1) {
27 + if ($[0] !== foo || $[1] !== bar) {
28 const x = { foo };
29 y = { bar };
30 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate-iife.expect.md
+1 -2
@@ -29,9 +29,8 @@ const { mutate } = require("shared-runtime");
29
30 function component(a) {
31 const $ = useMemoCache(2);
32 - const c_0 = $[0] !== a;
32 let y;
34 - if (c_0) {
33 + if ($[0] !== a) {
34 const x = { a };
35 y = {};
36
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md
+1 -2
@@ -21,9 +21,8 @@ function component(a) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function component(a) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== a;
24 let y;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 const x = { a };
27 y = {};
28 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate-iife.expect.md
+1 -2
@@ -29,9 +29,8 @@ const { mutate } = require("shared-runtime");
29
30 function component(a) {
31 const $ = useMemoCache(2);
32 - const c_0 = $[0] !== a;
32 let y;
34 - if (c_0) {
33 + if ($[0] !== a) {
34 const x = { a };
35 y = {};
36
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md
+1 -2
@@ -21,9 +21,8 @@ function component(a) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function component(a) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== a;
24 let y;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 const x = { a };
27 y = {};
28 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate-iife.expect.md
+1 -2
@@ -30,9 +30,8 @@ import { mutate } from "shared-runtime";
30
31 function component(a) {
32 const $ = useMemoCache(2);
33 - const c_0 = $[0] !== a;
33 let y;
35 - if (c_0) {
34 + if ($[0] !== a) {
35 const x = { a };
36 y = {};
37
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md
+1 -2
@@ -22,9 +22,8 @@ function component(a) {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function component(a) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== a;
25 let y;
27 - if (c_0) {
26 + if ($[0] !== a) {
27 const x = { a };
28 y = {};
29 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate-iife.expect.md
+1 -2
@@ -30,9 +30,8 @@ const { mutate } = require("shared-runtime");
30
31 function component(a) {
32 const $ = useMemoCache(2);
33 - const c_0 = $[0] !== a;
33 let y;
35 - if (c_0) {
34 + if ($[0] !== a) {
35 const x = { a };
36 y = {};
37
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md
+1 -2
@@ -22,9 +22,8 @@ function component(a) {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function component(a) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== a;
25 let y;
27 - if (c_0) {
26 + if ($[0] !== a) {
27 const x = { a };
28 y = {};
29 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-mutate-2.expect.md
+2 -5
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function component(a, b) {
29 const $ = useMemoCache(5);
30 - const c_0 = $[0] !== b;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== b) {
32 t0 = { b };
33 $[0] = b;
34 $[1] = t0;
@@ -37,10 +36,8 @@ function component(a, b) {
36 t0 = $[1];
37 }
38 const y = t0;
40 - const c_2 = $[2] !== a;
41 - const c_3 = $[3] !== y.b;
39 let z;
43 - if (c_2 || c_3) {
40 + if ($[2] !== a || $[3] !== y.b) {
41 z = { a };
42 const x = function () {
43 z.a = 2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-mutate-3.expect.md
+1 -2
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function component(a, b) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== a;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 t0 = { a };
32 $[0] = a;
33 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-mutate-nested.expect.md
+1 -2
@@ -25,9 +25,8 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function component(a) {
27 const $ = useMemoCache(2);
28 - const c_0 = $[0] !== a;
28 let y;
30 - if (c_0) {
29 + if ($[0] !== a) {
30 y = { b: { a } };
31 const x = function () {
32 y.b.a = 2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md
+1 -3
@@ -27,10 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function component(a, b) {
29 const $ = useMemoCache(3);
30 - const c_0 = $[0] !== a;
31 - const c_1 = $[1] !== b;
30 let z;
33 - if (c_0 || c_1) {
31 + if ($[0] !== a || $[1] !== b) {
32 z = { a };
33 const y = { b };
34 const x = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias-iife.expect.md
+1 -2
@@ -29,9 +29,8 @@ const { mutate } = require("shared-runtime");
29
30 function component(a) {
31 const $ = useMemoCache(2);
32 - const c_0 = $[0] !== a;
32 let y;
34 - if (c_0) {
33 + if ($[0] !== a) {
34 const x = { a };
35 y = {};
36
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md
+1 -2
@@ -21,9 +21,8 @@ function component(a) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function component(a) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== a;
24 let y;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 const x = { a };
27 y = {};
28 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-1.expect.md
+2 -4
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function component(a) {
26 const $ = useMemoCache(4);
27 - const c_0 = $[0] !== a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 t0 = { a };
30 $[0] = a;
31 $[1] = t0;
@@ -34,9 +33,8 @@ function component(a) {
33 t0 = $[1];
34 }
35 const z = t0;
37 - const c_2 = $[2] !== z;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== z) {
38 t1 = function () {
39 console.log(z);
40 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2-iife.expect.md
+1 -2
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function bar(a) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== a;
29 let y;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 const x = [a];
32 y = {};
33
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2.expect.md
+1 -2
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function bar(a) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== a;
30 let y;
32 - if (c_0) {
31 + if ($[0] !== a) {
32 const x = [a];
33 y = {};
34 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3-iife.expect.md
+1 -3
@@ -28,10 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function bar(a, b) {
30 const $ = useMemoCache(3);
31 - const c_0 = $[0] !== a;
32 - const c_1 = $[1] !== b;
31 let y;
34 - if (c_0 || c_1) {
32 + if ($[0] !== a || $[1] !== b) {
33 const x = [a, b];
34 y = {};
35 let t;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3.expect.md
+1 -3
@@ -29,10 +29,8 @@ export const FIXTURE_ENTRYPOINT = {
29 import { unstable_useMemoCache as useMemoCache } from "react";
30 function bar(a, b) {
31 const $ = useMemoCache(3);
32 - const c_0 = $[0] !== a;
33 - const c_1 = $[1] !== b;
32 let y;
35 - if (c_0 || c_1) {
33 + if ($[0] !== a || $[1] !== b) {
34 const x = [a, b];
35 y = {};
36 let t;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4-iife.expect.md
+1 -2
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function bar(a) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== a;
29 let y;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 const x = [a];
32 y = {};
33
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4.expect.md
+1 -2
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function bar(a) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== a;
30 let y;
32 - if (c_0) {
31 + if ($[0] !== a) {
32 const x = [a];
33 y = {};
34 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-iife.expect.md
+1 -2
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function bar(a) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== a;
29 let y;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 const x = [a];
32 y = {};
33
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load.expect.md
+1 -2
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function bar(a) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== a;
30 let y;
32 - if (c_0) {
31 + if ($[0] !== a) {
32 const x = [a];
33 y = {};
34 const f0 = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md
+3 -7
@@ -25,9 +25,8 @@ function component(a, b) {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function component(a, b) {
27 const $ = useMemoCache(7);
28 - const c_0 = $[0] !== a;
28 let z;
30 - if (c_0) {
29 + if ($[0] !== a) {
30 z = { a };
31
32 mutate(z);
@@ -38,9 +37,8 @@ function component(a, b) {
37 }
38
39 let y = z;
41 - const c_2 = $[2] !== b;
40 let t0;
43 - if (c_2) {
41 + if ($[2] !== b) {
42 t0 = { b };
43 $[2] = b;
44 $[3] = t0;
@@ -48,10 +46,8 @@ function component(a, b) {
46 t0 = $[3];
47 }
48 const z_0 = t0;
51 - const c_4 = $[4] !== y;
52 - const c_5 = $[5] !== z_0;
49 let t1;
54 - if (c_4 || c_5) {
50 + if ($[4] !== y || $[5] !== z_0) {
51 t1 = { y, z: z_0 };
52 $[4] = y;
53 $[5] = z_0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md
+2 -5
@@ -25,9 +25,8 @@ function component(a, b) {
25 import { unstable_useMemoCache as useMemoCache } from "react"; // @debug
26 function component(a, b) {
27 const $ = useMemoCache(5);
28 - const c_0 = $[0] !== a;
28 let t0;
30 - if (c_0) {
29 + if ($[0] !== a) {
30 t0 = { a };
31 $[0] = a;
32 $[1] = t0;
@@ -36,10 +35,8 @@ function component(a, b) {
35 }
36 const z = t0;
37 const y = b;
39 - const c_2 = $[2] !== y;
40 - const c_3 = $[3] !== z;
38 let t1;
42 - if (c_2 || c_3) {
39 + if ($[2] !== y || $[3] !== z) {
40 t1 = function () {
41 if (y) {
42 maybeMutate(z);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-decl.expect.md
+1 -2
@@ -25,9 +25,8 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function component(a) {
27 const $ = useMemoCache(2);
28 - const c_0 = $[0] !== a;
28 let t;
30 - if (c_0) {
29 + if ($[0] !== a) {
30 t = { a };
31 const x = function x() {
32 t.foo();
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-arguments.expect.md
+1 -2
@@ -21,9 +21,8 @@ function Foo(props) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function Foo(props) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== props.router.location;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== props.router.location) {
26 t0 = (reason) => {
27 log(props.router.location);
28 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md
+3 -7
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
23 function component(t26) {
24 const $ = useMemoCache(7);
25 const { mutator } = t26;
26 - const c_0 = $[0] !== mutator;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== mutator) {
28 t0 = () => {
29 mutator.poke();
30 };
@@ -35,9 +34,8 @@ function component(t26) {
34 t0 = $[1];
35 }
36 const poke = t0;
38 - const c_2 = $[2] !== mutator.user;
37 let t1;
40 - if (c_2) {
38 + if ($[2] !== mutator.user) {
39 t1 = () => {
40 mutator.user.hide();
41 };
@@ -47,10 +45,8 @@ function component(t26) {
45 t1 = $[3];
46 }
47 const hide = t1;
50 - const c_4 = $[4] !== poke;
51 - const c_5 = $[5] !== hide;
48 let t2;
53 - if (c_4 || c_5) {
49 + if ($[4] !== poke || $[5] !== hide) {
50 t2 = <Foo poke={poke} hide={hide} />;
51 $[4] = poke;
52 $[5] = hide;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md
+1 -2
@@ -21,9 +21,8 @@ function component(a, b) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function component(a, b) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== a;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 t0 = { a };
27 $[0] = a;
28 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md
+3 -6
@@ -16,9 +16,8 @@ function component(a, b) {
16 import { unstable_useMemoCache as useMemoCache } from "react";
17 function component(a, b) {
18 const $ = useMemoCache(6);
19 - const c_0 = $[0] !== a;
19 let t0;
21 - if (c_0) {
20 + if ($[0] !== a) {
21 t0 = { a };
22 $[0] = a;
23 $[1] = t0;
@@ -26,9 +25,8 @@ function component(a, b) {
25 t0 = $[1];
26 }
27 const z = t0;
29 - const c_2 = $[2] !== z;
28 let t1;
31 - if (c_2) {
29 + if ($[2] !== z) {
30 t1 = () => <Foo>{z}</Foo>;
31 $[2] = z;
32 $[3] = t1;
@@ -36,9 +34,8 @@ function component(a, b) {
34 t1 = $[3];
35 }
36 const p = t1;
39 - const c_4 = $[4] !== p;
37 let t2;
41 - if (c_4) {
38 + if ($[4] !== p) {
39 t2 = p();
40 $[4] = p;
41 $[5] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-skip-computed-path.expect.md
+1 -2
@@ -21,9 +21,8 @@ export const FIXTURE_ENTRYPOINT = {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function StoreLandingUnseenGiftModalContainer(a) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== a;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 const giftsSeen = { a };
27 t0 = ((gift) => (gift.id ? giftsSeen[gift.id] : false))();
28 $[0] = a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-function-within-block.expect.md
+2 -4
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function component(a) {
29 const $ = useMemoCache(4);
30 - const c_0 = $[0] !== a;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== a) {
32 t0 = { a };
33 $[0] = a;
34 $[1] = t0;
@@ -37,9 +36,8 @@ function component(a) {
36 t0 = $[1];
37 }
38 const z = t0;
40 - const c_2 = $[2] !== z;
39 let t1;
42 - if (c_2) {
40 + if ($[2] !== z) {
41 t1 = function () {
42 console.log(z);
43 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-member-expr.expect.md
+2 -4
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function component(a) {
26 const $ = useMemoCache(4);
27 - const c_0 = $[0] !== a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 t0 = { a };
30 $[0] = a;
31 $[1] = t0;
@@ -34,9 +33,8 @@ function component(a) {
33 t0 = $[1];
34 }
35 const z = t0;
37 - const c_2 = $[2] !== z.a;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== z.a) {
38 t1 = function () {
39 console.log(z.a);
40 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-nested-member-call.expect.md
+1 -2
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function component(a) {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 t0 = { a: { a } };
30 $[0] = a;
31 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr-in-nested-func.expect.md
+2 -4
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function component(a) {
28 const $ = useMemoCache(4);
29 - const c_0 = $[0] !== a;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 t0 = { a: { a } };
32 $[0] = a;
33 $[1] = t0;
@@ -36,9 +35,8 @@ function component(a) {
35 t0 = $[1];
36 }
37 const z = t0;
39 - const c_2 = $[2] !== z.a.a;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== z.a.a) {
40 t1 = function () {
41 (function () {
42 console.log(z.a.a);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr.expect.md
+2 -4
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function component(a) {
26 const $ = useMemoCache(4);
27 - const c_0 = $[0] !== a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 t0 = { a: { a } };
30 $[0] = a;
31 $[1] = t0;
@@ -34,9 +33,8 @@ function component(a) {
33 t0 = $[1];
34 }
35 const z = t0;
37 - const c_2 = $[2] !== z.a.a;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== z.a.a) {
38 t1 = function () {
39 console.log(z.a.a);
40 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-reference-changes-type.expect.md
+1 -2
@@ -20,9 +20,8 @@ function component(a) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function component(a) {
22 const $ = useMemoCache(2);
23 - const c_0 = $[0] !== a;
23 let y;
25 - if (c_0) {
24 + if ($[0] !== a) {
25 const x = { a };
26 y = 1;
27
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-block.expect.md
+2 -4
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function component(a) {
28 const $ = useMemoCache(4);
29 - const c_0 = $[0] !== a;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 t0 = { a };
32 $[0] = a;
33 $[1] = t0;
@@ -36,9 +35,8 @@ function component(a) {
35 t0 = $[1];
36 }
37 const z = t0;
39 - const c_2 = $[2] !== z;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== z) {
40 t1 = function () {
41 console.log(z);
42 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-function.expect.md
+2 -4
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function component(a) {
28 const $ = useMemoCache(4);
29 - const c_0 = $[0] !== a;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 t0 = { a };
32 $[0] = a;
33 $[1] = t0;
@@ -36,9 +35,8 @@ function component(a) {
35 t0 = $[1];
36 }
37 const z = t0;
39 - const c_2 = $[2] !== z;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== z) {
40 t1 = function () {
41 (function () {
42 console.log(z);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/codegen-emit-imports-same-source.expect.md
+1 -2
@@ -19,9 +19,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEmitFre
19 function useFoo(props) {
20 if (__DEV__) useRenderCounter("useFoo");
21 const $ = useMemoCache(2);
22 - const c_0 = $[0] !== props.x;
22 let t0;
24 - if (c_0) {
23 + if ($[0] !== props.x) {
24 t0 = foo(props.x);
25 $[0] = props.x;
26 $[1] = __DEV__ ? makeReadOnly(t0, "useFoo") : t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/codegen-emit-make-read-only.expect.md
+2 -5
@@ -24,10 +24,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEmitFre
24
25 function MyComponentName(props) {
26 const $ = useMemoCache(5);
27 - const c_0 = $[0] !== props.a;
28 - const c_1 = $[1] !== props.b;
27 let x;
30 - if (c_0 || c_1) {
28 + if ($[0] !== props.a || $[1] !== props.b) {
29 x = {};
30 foo(x, props.a);
31 foo(x, props.b);
@@ -37,9 +35,8 @@ function MyComponentName(props) {
35 } else {
36 x = $[2];
37 }
40 - const c_3 = $[3] !== x;
38 let y;
42 - if (c_3) {
39 + if ($[3] !== x) {
40 y = [];
41 y.push(x);
42 $[3] = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/codegen-instrument-forget-gating-test.expect.md
+2 -4
@@ -30,9 +30,8 @@ const Bar = isForgetEnabled_Fixtures()
30 ? function Bar(props) {
31 if (__DEV__) useRenderCounter("Bar");
32 const $ = useMemoCache(2);
33 - const c_0 = $[0] !== props.bar;
33 let t0;
35 - if (c_0) {
34 + if ($[0] !== props.bar) {
35 t0 = <div>{props.bar}</div>;
36 $[0] = props.bar;
37 $[1] = t0;
@@ -54,9 +53,8 @@ const Foo = isForgetEnabled_Fixtures()
53 ? function Foo(props) {
54 if (__DEV__) useRenderCounter("Foo");
55 const $ = useMemoCache(2);
57 - const c_0 = $[0] !== props.bar;
56 let t0;
59 - if (c_0) {
57 + if ($[0] !== props.bar) {
58 t0 = <Foo>{props.bar}</Foo>;
59 $[0] = props.bar;
60 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/codegen-instrument-forget-test.expect.md
+2 -4
@@ -29,9 +29,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @instrumentFor
29 function Bar(props) {
30 if (__DEV__) useRenderCounter("Bar");
31 const $ = useMemoCache(2);
32 - const c_0 = $[0] !== props.bar;
32 let t0;
34 - if (c_0) {
33 + if ($[0] !== props.bar) {
34 t0 = <div>{props.bar}</div>;
35 $[0] = props.bar;
36 $[1] = t0;
@@ -48,9 +47,8 @@ function NoForget(props) {
47 function Foo(props) {
48 if (__DEV__) useRenderCounter("Foo");
49 const $ = useMemoCache(2);
51 - const c_0 = $[0] !== props.bar;
50 let t0;
53 - if (c_0) {
51 + if ($[0] !== props.bar) {
52 t0 = <Foo>{props.bar}</Foo>;
53 $[0] = props.bar;
54 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/component-declaration-basic.flow.expect.md
+1 -2
@@ -17,9 +17,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
17 export default function Foo(t7) {
18 const $ = useMemoCache(2);
19 const { bar } = t7;
20 - const c_0 = $[0] !== bar;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== bar) {
22 t0 = <Bar bar={bar} />;
23 $[0] = bar;
24 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/component.expect.md
+3 -8
@@ -45,10 +45,8 @@ function Component(props) {
45 const $ = useMemoCache(8);
46 const items = props.items;
47 const maxItems = props.maxItems;
48 - const c_0 = $[0] !== maxItems;
49 - const c_1 = $[1] !== items;
48 let renderedItems;
51 - if (c_0 || c_1) {
49 + if ($[0] !== maxItems || $[1] !== items) {
50 renderedItems = [];
51 const seen = new Set();
52 const max = Math.max(0, maxItems);
@@ -72,19 +70,16 @@ function Component(props) {
70 }
71
72 const count = renderedItems.length;
75 - const c_3 = $[3] !== count;
73 let t0;
77 - if (c_3) {
74 + if ($[3] !== count) {
75 t0 = <h1>{count} Items</h1>;
76 $[3] = count;
77 $[4] = t0;
78 } else {
79 t0 = $[4];
80 }
84 - const c_5 = $[5] !== t0;
85 - const c_6 = $[6] !== renderedItems;
81 let t1;
87 - if (c_5 || c_6) {
82 + if ($[5] !== t0 || $[6] !== renderedItems) {
83 t1 = (
84 <div>
85 {t0}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/computed-call-spread.expect.md
+1 -4
@@ -15,11 +15,8 @@ function Component(props) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(4);
18 - const c_0 = $[0] !== props.method;
19 - const c_1 = $[1] !== props.a;
20 - const c_2 = $[2] !== props.b;
18 let t0;
22 - if (c_0 || c_1 || c_2) {
19 + if ($[0] !== props.method || $[1] !== props.a || $[2] !== props.b) {
20 t0 = foo[props.method](...props.a, null, ...props.b);
21 $[0] = props.method;
22 $[1] = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/computed-load-primitive-as-dependency.expect.md
+1 -2
@@ -23,9 +23,8 @@ function Component(props) {
23 const a = foo();
24
25 const t0 = a[props.a] + 1;
26 - const c_0 = $[0] !== t0;
26 let t1;
28 - if (c_0) {
27 + if ($[0] !== t0) {
28 t1 = bar(t0);
29 $[0] = t0;
30 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/computed-store-alias.expect.md
+1 -3
@@ -18,10 +18,8 @@ function component(a, b) {
18 import { unstable_useMemoCache as useMemoCache } from "react";
19 function component(a, b) {
20 const $ = useMemoCache(3);
21 - const c_0 = $[0] !== a;
22 - const c_1 = $[1] !== b;
21 let x;
24 - if (c_0 || c_1) {
22 + if ($[0] !== a || $[1] !== b) {
23 const y = { a };
24 x = { b };
25 x.y = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/concise-arrow-expr.expect.md
+1 -2
@@ -25,9 +25,8 @@ function component() {
25 t0 = $[0];
26 }
27 const handler = t0;
28 - const c_1 = $[1] !== handler;
28 let t1;
30 - if (c_1) {
29 + if ($[1] !== handler) {
30 t1 = <Foo handler={handler} />;
31 $[1] = handler;
32 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/cond-deps-conditional-member-expr.expect.md
+1 -2
@@ -29,9 +29,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // To preserve th
29
30 function Component(props) {
31 const $ = useMemoCache(2);
32 - const c_0 = $[0] !== props.a;
32 let x;
34 - if (c_0) {
33 + if ($[0] !== props.a) {
34 x = [];
35 x.push(props.a?.b);
36 $[0] = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-break-labeled.expect.md
+6 -5
@@ -35,12 +35,13 @@ import { unstable_useMemoCache as useMemoCache } from "react";
35 */
36 function Component(props) {
37 const $ = useMemoCache(5);
38 - const c_0 = $[0] !== props.a;
39 - const c_1 = $[1] !== props.b;
40 - const c_2 = $[2] !== props.c;
41 - const c_3 = $[3] !== props.d;
38 let a;
43 - if (c_0 || c_1 || c_2 || c_3) {
39 + if (
40 + $[0] !== props.a ||
41 + $[1] !== props.b ||
42 + $[2] !== props.c ||
43 + $[3] !== props.d
44 + ) {
45 a = [];
46 a.push(props.a);
47 bb1: {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-break.expect.md
+4 -10
@@ -67,11 +67,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
67 */
68 function ComponentA(props) {
69 const $ = useMemoCache(4);
70 - const c_0 = $[0] !== props.a;
71 - const c_1 = $[1] !== props.b;
72 - const c_2 = $[2] !== props.d;
70 let a_DEBUG;
74 - if (c_0 || c_1 || c_2) {
71 + if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.d) {
72 a_DEBUG = [];
73 a_DEBUG.push(props.a);
74 if (props.b) {
@@ -94,9 +91,8 @@ function ComponentA(props) {
91 */
92 function ComponentB(props) {
93 const $ = useMemoCache(2);
97 - const c_0 = $[0] !== props;
94 let a;
99 - if (c_0) {
95 + if ($[0] !== props) {
96 a = [];
97 a.push(props.a);
98 if (props.b) {
@@ -117,9 +113,8 @@ function ComponentB(props) {
113 */
114 function ComponentC(props) {
115 const $ = useMemoCache(2);
120 - const c_0 = $[0] !== props;
116 let a;
122 - if (c_0) {
117 + if ($[0] !== props) {
118 a = [];
119 a.push(props.a);
120 if (props.b) {
@@ -141,9 +136,8 @@ function ComponentC(props) {
136 */
137 function ComponentD(props) {
138 const $ = useMemoCache(2);
144 - const c_0 = $[0] !== props;
139 let a;
146 - if (c_0) {
140 + if ($[0] !== props) {
141 a = [];
142 a.push(props.a);
143 if (props.b) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md
+4 -10
@@ -37,10 +37,9 @@ function mayMutate() {}
37 import { unstable_useMemoCache as useMemoCache } from "react";
38 function ComponentA(props) {
39 const $ = useMemoCache(6);
40 - const c_0 = $[0] !== props;
40 let a;
41 let b;
43 - if (c_0) {
42 + if ($[0] !== props) {
43 a = [];
44 b = [];
45 if (b) {
@@ -56,10 +55,8 @@ function ComponentA(props) {
55 a = $[1];
56 b = $[2];
57 }
59 - const c_3 = $[3] !== a;
60 - const c_4 = $[4] !== b;
58 let t0;
62 - if (c_3 || c_4) {
59 + if ($[3] !== a || $[4] !== b) {
60 t0 = <Foo a={a} b={b} />;
61 $[3] = a;
62 $[4] = b;
@@ -72,10 +69,9 @@ function ComponentA(props) {
69
70 function ComponentB(props) {
71 const $ = useMemoCache(6);
75 - const c_0 = $[0] !== props;
72 let a;
73 let b;
78 - if (c_0) {
74 + if ($[0] !== props) {
75 a = [];
76 b = [];
77 if (mayMutate(b)) {
@@ -91,10 +87,8 @@ function ComponentB(props) {
87 a = $[1];
88 b = $[2];
89 }
94 - const c_3 = $[3] !== a;
95 - const c_4 = $[4] !== b;
90 let t0;
97 - if (c_3 || c_4) {
91 + if ($[3] !== a || $[4] !== b) {
92 t0 = <Foo a={a} b={b} />;
93 $[3] = a;
94 $[4] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/console-readonly.expect.md
+1 -2
@@ -32,9 +32,8 @@ import { shallowCopy } from "shared-runtime";
32
33 function Component(props) {
34 const $ = useMemoCache(2);
35 - const c_0 = $[0] !== props;
35 let t0;
37 - if (c_0) {
36 + if ($[0] !== props) {
37 t0 = shallowCopy(props);
38 $[0] = props;
39 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/constant-computed.expect.md
+1 -2
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== props.foo;
27 let x;
29 - if (c_0) {
28 + if ($[0] !== props.foo) {
29 x = {};
30 x.foo = x.foo + x.bar;
31 x.foo(props.foo);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/constant-propagate-global-phis.expect.md
+1 -2
@@ -39,9 +39,8 @@ function Test() {
39 const $ = useMemoCache(2);
40 const { tab } = useFoo();
41 const currentTab = tab === CONST_STRING0 ? CONST_STRING0 : CONST_STRING1;
42 - const c_0 = $[0] !== currentTab;
42 let t0;
44 - if (c_0) {
43 + if ($[0] !== currentTab) {
44 t0 = <Text value={currentTab} />;
45 $[0] = currentTab;
46 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/controlled-input.expect.md
+1 -3
@@ -32,10 +32,8 @@ function component() {
32 t0 = $[0];
33 }
34 const handler = t0;
35 - const c_1 = $[1] !== handler;
36 - const c_2 = $[2] !== x;
35 let t1;
38 - if (c_1 || c_2) {
36 + if ($[1] !== handler || $[2] !== x) {
37 t1 = <input onChange={handler} value={x} />;
38 $[1] = handler;
39 $[2] = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/debugger-memoized.expect.md
+1 -2
@@ -23,9 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== props.value;
26 let x;
28 - if (c_0) {
27 + if ($[0] !== props.value) {
28 x = [];
29 debugger;
30
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/default-param-array-with-unary.expect.md
+1 -2
@@ -19,9 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(t0) {
21 const $ = useMemoCache(2);
22 - const c_0 = $[0] !== t0;
22 let t1;
24 - if (c_0) {
23 + if ($[0] !== t0) {
24 t1 = t0 === undefined ? [-1, 1] : t0;
25 $[0] = t0;
26 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/default-param-calls-global-function.expect.md
+1 -2
@@ -23,9 +23,8 @@ import { identity } from "shared-runtime";
23
24 function Component(t0) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== t0;
26 let t1;
28 - if (c_0) {
27 + if ($[0] !== t0) {
28 t1 = t0 === undefined ? identity([() => {}, true, 42, "hello"]) : t0;
29 $[0] = t0;
30 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/default-param-with-empty-callback.expect.md
+1 -2
@@ -19,9 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(t0) {
21 const $ = useMemoCache(2);
22 - const c_0 = $[0] !== t0;
22 let t1;
24 - if (c_0) {
23 + if ($[0] !== t0) {
24 t1 = t0 === undefined ? () => {} : t0;
25 $[0] = t0;
26 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/default-param-with-reorderable-callback.expect.md
+1 -2
@@ -19,9 +19,8 @@ export const FIXTURE_ENTRYPOINT = {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(t0) {
21 const $ = useMemoCache(2);
22 - const c_0 = $[0] !== t0;
22 let t1;
24 - if (c_0) {
23 + if ($[0] !== t0) {
24 t1 = t0 === undefined ? () => [-1, true, 42, "hello"] : t0;
25 $[0] = t0;
26 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/delete-computed-property.expect.md
+1 -3
@@ -23,10 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(3);
26 - const c_0 = $[0] !== props.a;
27 - const c_1 = $[1] !== props.b;
26 let x;
29 - if (c_0 || c_1) {
27 + if ($[0] !== props.a || $[1] !== props.b) {
28 x = { a: props.a, b: props.b };
29 delete x["b"];
30 $[0] = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/delete-property.expect.md
+1 -3
@@ -22,10 +22,8 @@ export const FIXTURE_ENTRYPOINT = {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function Component(props) {
24 const $ = useMemoCache(3);
25 - const c_0 = $[0] !== props.a;
26 - const c_1 = $[1] !== props.b;
25 let x;
28 - if (c_0 || c_1) {
26 + if ($[0] !== props.a || $[1] !== props.b) {
27 x = { a: props.a, b: props.b };
28 delete x.b;
29 $[0] = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/dependencies-outputs.expect.md
+2 -5
@@ -31,9 +31,8 @@ export const FIXTURE_ENTRYPOINT = {
31 import { unstable_useMemoCache as useMemoCache } from "react";
32 function foo(a, b) {
33 const $ = useMemoCache(5);
34 - const c_0 = $[0] !== a;
34 let x;
36 - if (c_0) {
35 + if ($[0] !== a) {
36 x = [];
37 x.push(a);
38 $[0] = a;
@@ -41,10 +40,8 @@ function foo(a, b) {
40 } else {
41 x = $[1];
42 }
44 - const c_2 = $[2] !== x;
45 - const c_3 = $[3] !== b;
43 let y;
47 - if (c_2 || c_3) {
44 + if ($[2] !== x || $[3] !== b) {
45 y = [];
46 if (x.length) {
47 y.push(x);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/dependencies.expect.md
+1 -3
@@ -34,10 +34,8 @@ function foo(x, y, z) {
34 const $ = useMemoCache(3);
35 const items = [z];
36 items.push(x);
37 - const c_0 = $[0] !== x;
38 - const c_1 = $[1] !== y;
37 let items2;
40 - if (c_0 || c_1) {
38 + if ($[0] !== x || $[1] !== y) {
39 items2 = [];
40 if (x) {
41 items2.push(y);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-capture-global.expect.md
+1 -2
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
23 let someGlobal = {};
24 function component(a) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== a;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 t0 = { a, someGlobal };
29 $[0] = a;
30 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-default-array-with-unary.expect.md
+1 -2
@@ -21,9 +21,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(2);
23 const [t0] = props.value;
24 - const c_0 = $[0] !== t0;
24 let t1;
26 - if (c_0) {
25 + if ($[0] !== t0) {
26 t1 = t0 === undefined ? [-1, 1] : t0;
27 $[0] = t0;
28 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md
+1 -2
@@ -22,9 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(2);
24 const [t0] = props.y;
25 - const c_0 = $[0] !== t0;
25 let t1;
27 - if (c_0) {
26 + if ($[0] !== t0) {
27 t1 = t0 === undefined ? ["default"] : t0;
28 $[0] = t0;
29 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md
+1 -2
@@ -29,9 +29,8 @@ function Component(props) {
29 let x = undefined;
30 if (props.cond) {
31 const [t0] = props.y;
32 - const c_0 = $[0] !== t0;
32 let t1;
34 - if (c_0) {
33 + if ($[0] !== t0) {
34 t1 = t0 === undefined ? ["default"] : t0;
35 $[0] = t0;
36 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md
+1 -5
@@ -44,12 +44,8 @@ function foo(a, b, c) {
44 const { m: t58 } = t55;
45 const [t60] = t58;
46 const [n] = t60;
47 - const c_0 = $[0] !== d;
48 - const c_1 = $[1] !== g;
49 - const c_2 = $[2] !== n;
50 - const c_3 = $[3] !== o;
47 let t0;
52 - if (c_0 || c_1 || c_2 || c_3) {
48 + if ($[0] !== d || $[1] !== g || $[2] !== n || $[3] !== o) {
49 t0 = { d, g, n, o };
50 $[0] = d;
51 $[1] = g;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md
+6 -14
@@ -58,17 +58,15 @@ function useFragment(_arg1, _arg2) {
58 function Component(props) {
59 const $ = useMemoCache(16);
60 const post = useFragment(graphql`...`, props.post);
61 - const c_0 = $[0] !== post;
61 let media;
62 let allUrls;
63 let onClick;
65 - if (c_0) {
64 + if ($[0] !== post) {
65 allUrls = [];
66
67 const { media: t0, comments: t2, urls: t4 } = post;
69 - const c_4 = $[4] !== t0;
68 let t1;
71 - if (c_4) {
69 + if ($[4] !== t0) {
70 t1 = t0 === undefined ? null : t0;
71 $[4] = t0;
72 $[5] = t1;
@@ -76,9 +74,8 @@ function Component(props) {
74 t1 = $[5];
75 }
76 media = t1;
79 - const c_6 = $[6] !== t2;
77 let t3;
81 - if (c_6) {
78 + if ($[6] !== t2) {
79 t3 = t2 === undefined ? [] : t2;
80 $[6] = t2;
81 $[7] = t3;
@@ -86,9 +83,8 @@ function Component(props) {
83 t3 = $[7];
84 }
85 const comments = t3;
89 - const c_8 = $[8] !== t4;
86 let t5;
91 - if (c_8) {
87 + if ($[8] !== t4) {
88 t5 = t4 === undefined ? [] : t4;
89 $[8] = t4;
90 $[9] = t5;
@@ -96,9 +92,8 @@ function Component(props) {
92 t5 = $[9];
93 }
94 const urls = t5;
99 - const c_10 = $[10] !== comments.length;
95 let t6;
101 - if (c_10) {
96 + if ($[10] !== comments.length) {
97 t6 = (e) => {
98 if (!comments.length) {
99 return;
@@ -123,11 +118,8 @@ function Component(props) {
118 allUrls = $[2];
119 onClick = $[3];
120 }
126 - const c_12 = $[12] !== media;
127 - const c_13 = $[13] !== allUrls;
128 - const c_14 = $[14] !== onClick;
121 let t7;
130 - if (c_12 || c_13 || c_14) {
122 + if ($[12] !== media || $[13] !== allUrls || $[14] !== onClick) {
123 t7 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
124 $[12] = media;
125 $[13] = allUrls;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md
+3 -7
@@ -32,17 +32,15 @@ import { unstable_useMemoCache as useMemoCache } from "react";
32 function Component(props) {
33 const $ = useMemoCache(8);
34 const post = useFragment(graphql`...`, props.post);
35 - const c_0 = $[0] !== post;
35 let media;
36 let onClick;
38 - if (c_0) {
37 + if ($[0] !== post) {
38 const allUrls = [];
39
40 const { media: t83, comments, urls } = post;
41 media = t83;
43 - const c_3 = $[3] !== comments.length;
42 let t0;
45 - if (c_3) {
43 + if ($[3] !== comments.length) {
44 t0 = (e) => {
45 if (!comments.length) {
46 return;
@@ -65,10 +63,8 @@ function Component(props) {
63 media = $[1];
64 onClick = $[2];
65 }
68 - const c_5 = $[5] !== media;
69 - const c_6 = $[6] !== onClick;
66 let t1;
71 - if (c_5 || c_6) {
67 + if ($[5] !== media || $[6] !== onClick) {
68 t1 = <Media media={media} onClick={onClick} />;
69 $[5] = media;
70 $[6] = onClick;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md
+1 -2
@@ -22,9 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(2);
24 const { x: t0 } = props.y;
25 - const c_0 = $[0] !== t0;
25 let t1;
27 - if (c_0) {
26 + if ($[0] !== t0) {
27 t1 = t0 === undefined ? { y: "default" } : t0;
28 $[0] = t0;
29 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-object-pattern-within-rest.expect.md
+2 -5
@@ -20,10 +20,9 @@ export const FIXTURE_ENTRYPOINT = {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(6);
23 - const c_0 = $[0] !== props.value;
23 let t0;
24 let y;
26 - if (c_0) {
25 + if ($[0] !== props.value) {
26 [y, ...t0] = props.value;
27 $[0] = props.value;
28 $[1] = t0;
@@ -33,10 +32,8 @@ function Component(props) {
32 y = $[2];
33 }
34 const { z } = t0;
36 - const c_3 = $[3] !== y;
37 - const c_4 = $[4] !== z;
35 let t1;
39 - if (c_3 || c_4) {
36 + if ($[3] !== y || $[4] !== z) {
37 t1 = [y, z];
38 $[3] = y;
39 $[4] = z;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-property-inference.expect.md
+2 -5
@@ -18,9 +18,8 @@ function Component(props) {
18 import { unstable_useMemoCache as useMemoCache } from "react";
19 function Component(props) {
20 const $ = useMemoCache(5);
21 - const c_0 = $[0] !== props.value;
21 let x;
23 - if (c_0) {
22 + if ($[0] !== props.value) {
23 x = [];
24 x.push(props.value);
25 $[0] = props.value;
@@ -30,10 +29,8 @@ function Component(props) {
29 }
30 const { length: y } = x;
31 foo(y);
33 - const c_2 = $[2] !== x;
34 - const c_3 = $[3] !== y;
32 let t0;
36 - if (c_2 || c_3) {
33 + if ($[2] !== x || $[3] !== y) {
34 t0 = [x, y];
35 $[2] = x;
36 $[3] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-with-typecast-as-default-value.flow.expect.md
+1 -2
@@ -21,9 +21,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(2);
23 const [t0] = props.y;
24 - const c_0 = $[0] !== t0;
24 let t1;
26 - if (c_0) {
25 + if ($[0] !== t0) {
26 t1 = t0 === undefined ? ([]: Array<number>) : t0;
27 $[0] = t0;
28 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring.expect.md
+12 -14
@@ -36,11 +36,10 @@ export const FIXTURE_ENTRYPOINT = {
36 import { unstable_useMemoCache as useMemoCache } from "react";
37 function foo(a, b, c) {
38 const $ = useMemoCache(18);
39 - const c_0 = $[0] !== a;
39 let t0;
40 let d;
41 let h;
43 - if (c_0) {
42 + if ($[0] !== a) {
43 [d, t0, ...h] = a;
44 $[0] = a;
45 $[1] = t0;
@@ -52,10 +51,9 @@ function foo(a, b, c) {
51 h = $[3];
52 }
53 const [t1] = t0;
55 - const c_4 = $[4] !== t1;
54 let t2;
55 let g;
58 - if (c_4) {
56 + if ($[4] !== t1) {
57 ({ e: t2, ...g } = t1);
58 $[4] = t1;
59 $[5] = t2;
@@ -67,10 +65,9 @@ function foo(a, b, c) {
65 const { f } = t2;
66 const { l: t51, p } = b;
67 const { m: t3 } = t51;
70 - const c_7 = $[7] !== t3;
68 let t4;
69 let o;
73 - if (c_7) {
70 + if ($[7] !== t3) {
71 [t4, ...o] = t3;
72 $[7] = t3;
73 $[8] = t4;
@@ -80,15 +77,16 @@ function foo(a, b, c) {
77 o = $[9];
78 }
79 const [n] = t4;
83 - const c_10 = $[10] !== d;
84 - const c_11 = $[11] !== f;
85 - const c_12 = $[12] !== g;
86 - const c_13 = $[13] !== h;
87 - const c_14 = $[14] !== n;
88 - const c_15 = $[15] !== o;
89 - const c_16 = $[16] !== p;
80 let t5;
91 - if (c_10 || c_11 || c_12 || c_13 || c_14 || c_15 || c_16) {
81 + if (
82 + $[10] !== d ||
83 + $[11] !== f ||
84 + $[12] !== g ||
85 + $[13] !== h ||
86 + $[14] !== n ||
87 + $[15] !== o ||
88 + $[16] !== p
89 + ) {
90 t5 = [d, f, g, h, n, o, p];
91 $[10] = d;
92 $[11] = f;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/do-while-compound-test.expect.md
+1 -2
@@ -26,9 +26,8 @@ export const FIXTURE_ENTRYPOINT = {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function Component(props) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== props;
29 let ret;
31 - if (c_0) {
30 + if ($[0] !== props) {
31 const x = [1, 2, 3];
32 ret = [];
33 do {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/do-while-conditional-break.expect.md
+1 -2
@@ -21,9 +21,8 @@ function Component(props) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== props;
24 let x;
26 - if (c_0) {
25 + if ($[0] !== props) {
26 x = [0, 1, 2, 3];
27 do {
28 if (x === 0) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usecallback.expect.md
+2 -4
@@ -26,9 +26,8 @@ import * as React from "react";
26
27 function Component(props) {
28 const $ = useMemoCache(4);
29 - const c_0 = $[0] !== props.value;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== props.value) {
31 t0 = () => {
32 console.log(props.value);
33 };
@@ -38,9 +37,8 @@ function Component(props) {
37 t0 = $[1];
38 }
39 const onClick = t0;
41 - const c_2 = $[2] !== onClick;
40 let t1;
43 - if (c_2) {
41 + if ($[2] !== onClick) {
42 t1 = <div onClick={onClick} />;
43 $[2] = onClick;
44 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usememo.expect.md
+1 -2
@@ -29,9 +29,8 @@ import * as React from "react";
29 function Component(props) {
30 const $ = useMemoCache(2);
31 let t42;
32 - const c_0 = $[0] !== props.value;
32 let x;
34 - if (c_0) {
33 + if ($[0] !== props.value) {
34 x = [];
35 x.push(props.value);
36 $[0] = props.value;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md
+3 -7
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(7);
27 - const c_0 = $[0] !== props.a;
27 let b;
29 - if (c_0) {
28 + if ($[0] !== props.a) {
29 const { a, ...t29 } = props.a;
30 b = t29;
31 $[0] = props.a;
@@ -34,9 +33,8 @@ function Component(props) {
33 } else {
34 b = $[1];
35 }
37 - const c_2 = $[2] !== props.c;
36 let d;
39 - if (c_2) {
37 + if ($[2] !== props.c) {
38 const [c, ...t30] = props.c;
39 d = t30;
40 $[2] = props.c;
@@ -44,10 +42,8 @@ function Component(props) {
42 } else {
43 d = $[3];
44 }
47 - const c_4 = $[4] !== b;
48 - const c_5 = $[5] !== d;
45 let t0;
50 - if (c_4 || c_5) {
46 + if ($[4] !== b || $[5] !== d) {
47 t0 = <div b={b} d={d} />;
48 $[4] = b;
49 $[5] = d;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-jsx-child.expect.md
+3 -9
@@ -28,17 +28,12 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function foo(a, b, c) {
30 const $ = useMemoCache(9);
31 - const c_0 = $[0] !== a;
32 - const c_1 = $[1] !== b;
33 - const c_2 = $[2] !== c;
31 let x;
35 - if (c_0 || c_1 || c_2) {
32 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
33 x = [];
34 if (a) {
38 - const c_4 = $[4] !== b;
39 - const c_5 = $[5] !== c;
35 let y;
41 - if (c_4 || c_5) {
36 + if ($[4] !== b || $[5] !== c) {
37 y = [];
38 if (b) {
39 y.push(c);
@@ -49,9 +44,8 @@ function foo(a, b, c) {
44 } else {
45 y = $[6];
46 }
52 - const c_7 = $[7] !== y;
47 let t0;
54 - if (c_7) {
48 + if ($[7] !== y) {
49 t0 = <div>{y}</div>;
50 $[7] = y;
51 $[8] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-logical.expect.md
+4 -10
@@ -25,9 +25,8 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function Component(props) {
27 const $ = useMemoCache(10);
28 - const c_0 = $[0] !== props.a;
28 let t0;
30 - if (c_0) {
29 + if ($[0] !== props.a) {
30 t0 = [props.a];
31 $[0] = props.a;
32 $[1] = t0;
@@ -35,9 +34,8 @@ function Component(props) {
34 t0 = $[1];
35 }
36 const a = t0;
38 - const c_2 = $[2] !== props.b;
37 let t1;
40 - if (c_2) {
38 + if ($[2] !== props.b) {
39 t1 = [props.b];
40 $[2] = props.b;
41 $[3] = t1;
@@ -45,9 +43,8 @@ function Component(props) {
43 t1 = $[3];
44 }
45 const b = t1;
48 - const c_4 = $[4] !== props.c;
46 let t2;
50 - if (c_4) {
47 + if ($[4] !== props.c) {
48 t2 = [props.c];
49 $[4] = props.c;
50 $[5] = t2;
@@ -55,11 +52,8 @@ function Component(props) {
52 t2 = $[5];
53 }
54 const c = t2;
58 - const c_6 = $[6] !== a;
59 - const c_7 = $[7] !== b;
60 - const c_8 = $[8] !== c;
55 let t3;
62 - if (c_6 || c_7 || c_8) {
56 + if ($[6] !== a || $[7] !== b || $[8] !== c) {
57 t3 = (a && b) || c;
58 $[6] = a;
59 $[7] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-dependency.expect.md
+2 -5
@@ -32,9 +32,8 @@ export const FIXTURE_ENTRYPOINT = {
32 import { unstable_useMemoCache as useMemoCache } from "react";
33 function Component(props) {
34 const $ = useMemoCache(5);
35 - const c_0 = $[0] !== props.a;
35 let t0;
37 - if (c_0) {
36 + if ($[0] !== props.a) {
37 t0 = [props.a];
38 $[0] = props.a;
39 $[1] = t0;
@@ -42,10 +41,8 @@ function Component(props) {
41 t0 = $[1];
42 }
43 const a = t0;
45 - const c_2 = $[2] !== a;
46 - const c_3 = $[3] !== props.b;
44 let b;
48 - if (c_2 || c_3) {
45 + if ($[2] !== a || $[3] !== props.b) {
46 b = [];
47 const c = {};
48 c.a = a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md
+3 -7
@@ -41,9 +41,8 @@ export const FIXTURE_ENTRYPOINT = {
41 import { unstable_useMemoCache as useMemoCache } from "react";
42 function Component(props) {
43 const $ = useMemoCache(7);
44 - const c_0 = $[0] !== props.a;
44 let t0;
46 - if (c_0) {
45 + if ($[0] !== props.a) {
46 t0 = [props.a];
47 $[0] = props.a;
48 $[1] = t0;
@@ -51,9 +50,8 @@ function Component(props) {
50 t0 = $[1];
51 }
52 const a = t0;
54 - const c_2 = $[2] !== a;
53 let t1;
56 - if (c_2) {
54 + if ($[2] !== a) {
55 t1 = [a];
56 $[2] = a;
57 $[3] = t1;
@@ -61,10 +59,8 @@ function Component(props) {
59 t1 = $[3];
60 }
61 const b = t1;
64 - const c_4 = $[4] !== b;
65 - const c_5 = $[5] !== props.b;
62 let c;
67 - if (c_4 || c_5) {
63 + if ($[4] !== b || $[5] !== props.b) {
64 c = [];
65 const d = {};
66 d.b = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-primitive-dependency.expect.md
+1 -3
@@ -36,10 +36,8 @@ function Component(props) {
36 const $ = useMemoCache(3);
37
38 const a = props.a + props.b;
39 - const c_0 = $[0] !== a;
40 - const c_1 = $[1] !== props.c;
39 let b;
42 - if (c_0 || c_1) {
40 + if ($[0] !== a || $[1] !== props.c) {
41 b = [];
42 const c = {};
43 c.a = a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/extend-scopes-if.expect.md
+1 -4
@@ -31,11 +31,8 @@ export const FIXTURE_ENTRYPOINT = {
31 import { unstable_useMemoCache as useMemoCache } from "react";
32 function foo(a, b, c) {
33 const $ = useMemoCache(4);
34 - const c_0 = $[0] !== a;
35 - const c_1 = $[1] !== b;
36 - const c_2 = $[2] !== c;
34 let x;
38 - if (c_0 || c_1 || c_2) {
35 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
36 x = [];
37 if (a) {
38 if (b) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md
+2 -4
@@ -22,9 +22,8 @@ import fbt from "fbt";
22
23 function Component(props) {
24 const $ = useMemoCache(4);
25 - const c_0 = $[0] !== props.name;
25 let t0;
27 - if (c_0) {
26 + if ($[0] !== props.name) {
27 t0 = fbt._(
28 "Hello, {(key) name}!",
29 [fbt._param("(key) name", capitalize(props.name))],
@@ -36,9 +35,8 @@ function Component(props) {
35 t0 = $[1];
36 }
37 const text = t0;
39 - const c_2 = $[2] !== text;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== text) {
40 t1 = <div>{text}</div>;
41 $[2] = text;
42 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-call.expect.md
+2 -4
@@ -22,9 +22,8 @@ import fbt from "fbt";
22
23 function Component(props) {
24 const $ = useMemoCache(4);
25 - const c_0 = $[0] !== props.count;
25 let t0;
27 - if (c_0) {
26 + if ($[0] !== props.count) {
27 t0 = fbt._(
28 "{(key) count} items",
29 [fbt._param("(key) count", props.count)],
@@ -36,9 +35,8 @@ function Component(props) {
35 t0 = $[1];
36 }
37 const text = t0;
39 - const c_2 = $[2] !== text;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== text) {
40 t1 = <div>{text}</div>;
41 $[2] = text;
42 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-params-complex-param-value.expect.md
+1 -2
@@ -22,9 +22,8 @@ import fbt from "fbt";
22
23 function Component(props) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== props.name;
25 let t0;
27 - if (c_0) {
26 + if ($[0] !== props.name) {
27 t0 = fbt._(
28 "Hello {user name}",
29 [fbt._param("user name", capitalize(props.name))],
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-params.expect.md
+1 -2
@@ -28,9 +28,8 @@ import fbt from "fbt";
28
29 function Component(props) {
30 const $ = useMemoCache(2);
31 - const c_0 = $[0] !== props.name;
31 let t0;
33 - if (c_0) {
32 + if ($[0] !== props.name) {
33 t0 = fbt._("Hello {user name}", [fbt._param("user name", props.name)], {
34 hk: "2zEDKF",
35 });
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-preserve-jsxtext.expect.md
+1 -2
@@ -27,9 +27,8 @@ import fbt from "fbt";
27
28 function Foo(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.value;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== props.value) {
32 t0 = fbt._(
33 { "0": "hello {value},", "1": "goodbye {value}," },
34 [
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-template-string-same-scope.expect.md
+2 -4
@@ -34,9 +34,8 @@ export function Component(props) {
34 if (props.items) {
35 count = props.items.length;
36 }
37 - const c_0 = $[0] !== count;
37 let t0;
39 - if (c_0) {
38 + if ($[0] !== count) {
39 t0 = fbt._("for {count} experiences", [fbt._param("count", count)], {
40 hk: "nmYpm",
41 });
@@ -45,9 +44,8 @@ export function Component(props) {
44 } else {
45 t0 = $[1];
46 }
48 - const c_2 = $[2] !== t0;
47 let t1;
50 - if (c_2) {
48 + if ($[2] !== t0) {
49 t1 = <View>{t0}</View>;
50 $[2] = t0;
51 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbtparam-with-jsx-element-content.expect.md
+1 -4
@@ -31,11 +31,8 @@ import fbt from "fbt";
31 function Component(t29) {
32 const $ = useMemoCache(4);
33 const { name, data, icon } = t29;
34 - const c_0 = $[0] !== name;
35 - const c_1 = $[1] !== icon;
36 - const c_2 = $[2] !== data;
34 let t0;
38 - if (c_0 || c_1 || c_2) {
35 + if ($[0] !== name || $[1] !== icon || $[2] !== data) {
36 t0 = (
37 <Text type="body4">
38 {fbt._(
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbtparam-with-jsx-fragment-value.expect.md
+1 -2
@@ -28,9 +28,8 @@ import { identity } from "shared-runtime";
28
29 function Component(props) {
30 const $ = useMemoCache(2);
31 - const c_0 = $[0] !== props.text;
31 let t0;
33 - if (c_0) {
32 + if ($[0] !== props.text) {
33 t0 = (
34 <Foo
35 value={fbt._(
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/for-in-statement-break.expect.md
+1 -2
@@ -28,9 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function Component(props) {
30 const $ = useMemoCache(2);
31 - const c_0 = $[0] !== props.value;
31 let x;
33 - if (c_0) {
32 + if ($[0] !== props.value) {
33 const object = { ...props.value };
34 for (const y in object) {
35 if (y === "break") {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/for-in-statement-continue.expect.md
+1 -2
@@ -29,9 +29,8 @@ function Component(props) {
29 const $ = useMemoCache(3);
30 let x;
31 if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
32 - const c_1 = $[1] !== props.value;
32 let t0;
34 - if (c_1) {
33 + if ($[1] !== props.value) {
34 t0 = { ...props.value };
35 $[1] = props.value;
36 $[2] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/for-in-statement.expect.md
+2 -4
@@ -23,9 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(4);
26 - const c_0 = $[0] !== props;
26 let items;
28 - if (c_0) {
27 + if ($[0] !== props) {
28 items = [];
29 for (const key in props) {
30 items.push(<div key={key}>{key}</div>);
@@ -35,9 +34,8 @@ function Component(props) {
34 } else {
35 items = $[1];
36 }
38 - const c_2 = $[2] !== items;
37 let t0;
40 - if (c_2) {
38 + if ($[2] !== items) {
39 t0 = <div>{items}</div>;
40 $[2] = items;
41 $[3] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-declaration-simple.expect.md
+1 -2
@@ -25,9 +25,8 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function component(a) {
27 const $ = useMemoCache(3);
28 - const c_0 = $[0] !== a;
28 let t;
30 - if (c_0) {
29 + if ($[0] !== a) {
30 t = { a };
31 let t0;
32 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-expression-maybe-mutates-hook-return-value.expect.md
+2 -4
@@ -24,9 +24,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(4);
26 const id = useSelectedEntitytId();
27 - const c_0 = $[0] !== id;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== id) {
29 t0 = () => {
30 log(id);
31 };
@@ -36,9 +35,8 @@ function Component(props) {
35 t0 = $[1];
36 }
37 const onLoad = t0;
39 - const c_2 = $[2] !== onLoad;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== onLoad) {
40 t1 = <Foo onLoad={onLoad} />;
41 $[2] = onLoad;
42 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-expression-with-store-to-parameter.expect.md
+1 -2
@@ -31,9 +31,8 @@ function Component(props) {
31 t0 = $[0];
32 }
33 const mutate = t0;
34 - const c_1 = $[1] !== props;
34 let x;
36 - if (c_1) {
35 + if ($[1] !== props) {
36 x = makeObject(props);
37 mutate(x);
38 $[1] = props;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md
+2 -5
@@ -21,9 +21,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(t23, t0) {
22 const $ = useMemoCache(5);
23 const x = t23 === undefined ? "default" : t23;
24 - const c_0 = $[0] !== t0;
24 let t1;
26 - if (c_0) {
25 + if ($[0] !== t0) {
26 t1 = t0 === undefined ? [{}] : t0;
27 $[0] = t0;
28 $[1] = t1;
@@ -31,10 +30,8 @@ function Component(t23, t0) {
30 t1 = $[1];
31 }
32 const y = t1;
34 - const c_2 = $[2] !== x;
35 - const c_3 = $[3] !== y;
33 let t2;
37 - if (c_2 || c_3) {
34 + if ($[2] !== x || $[3] !== y) {
35 t2 = [x, y];
36 $[2] = x;
37 $[3] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md
+2 -4
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @compi
27 export default isForgetEnabled_Fixtures()
28 ? function Bar(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.bar;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== props.bar) {
32 t0 = <div>{props.bar}</div>;
33 $[0] = props.bar;
34 $[1] = t0;
@@ -49,9 +48,8 @@ function NoForget(props) {
48 const Foo = isForgetEnabled_Fixtures()
49 ? function Foo(props) {
50 const $ = useMemoCache(2);
52 - const c_0 = $[0] !== props.bar;
51 let t0;
54 - if (c_0) {
52 + if ($[0] !== props.bar) {
53 t0 = <Foo>{props.bar}</Foo>;
54 $[0] = props.bar;
55 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md
+2 -4
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @compi
27 export default isForgetEnabled_Fixtures()
28 ? function Bar(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.bar;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== props.bar) {
32 t0 = <div>{props.bar}</div>;
33 $[0] = props.bar;
34 $[1] = t0;
@@ -50,9 +49,8 @@ function NoForget(props) {
49 export const Foo = isForgetEnabled_Fixtures()
50 ? function Foo(props) {
51 const $ = useMemoCache(2);
53 - const c_0 = $[0] !== props.bar;
52 let t0;
55 - if (c_0) {
53 + if ($[0] !== props.bar) {
54 t0 = <Foo>{props.bar}</Foo>;
55 $[0] = props.bar;
56 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md
+2 -4
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @compi
27 export const Bar = isForgetEnabled_Fixtures()
28 ? function Bar(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.bar;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== props.bar) {
32 t0 = <div>{props.bar}</div>;
33 $[0] = props.bar;
34 $[1] = t0;
@@ -50,9 +49,8 @@ export function NoForget(props) {
49 export const Foo = isForgetEnabled_Fixtures()
50 ? function Foo(props) {
51 const $ = useMemoCache(2);
53 - const c_0 = $[0] !== props.bar;
52 let t0;
55 - if (c_0) {
53 + if ($[0] !== props.bar) {
54 t0 = <Foo>{props.bar}</Foo>;
55 $[0] = props.bar;
56 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test.expect.md
+2 -4
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @compi
27 const Bar = isForgetEnabled_Fixtures()
28 ? function Bar(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.bar;
30 let t0;
32 - if (c_0) {
31 + if ($[0] !== props.bar) {
32 t0 = <div>{props.bar}</div>;
33 $[0] = props.bar;
34 $[1] = t0;
@@ -49,9 +48,8 @@ function NoForget(props) {
48 const Foo = isForgetEnabled_Fixtures()
49 ? function Foo(props) {
50 const $ = useMemoCache(2);
52 - const c_0 = $[0] !== props.bar;
51 let t0;
54 - if (c_0) {
52 + if ($[0] !== props.bar) {
53 t0 = <Foo>{props.bar}</Foo>;
54 $[0] = props.bar;
55 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hoisting-nested-const-declaration-2.expect.md
+1 -2
@@ -28,9 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function hoisting(cond) {
30 const $ = useMemoCache(3);
31 - const c_0 = $[0] !== cond;
31 let items;
33 - if (c_0) {
32 + if ($[0] !== cond) {
33 items = [];
34 if (cond) {
35 const foo = () => {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/holey-array-expr.expect.md
+1 -2
@@ -25,9 +25,8 @@ import { CONST_STRING0 } from "shared-runtime";
25
26 function t(props) {
27 const $ = useMemoCache(2);
28 - const c_0 = $[0] !== props;
28 let t0;
30 - if (c_0) {
29 + if ($[0] !== props) {
30 t0 = [, CONST_STRING0, props];
31 $[0] = props;
32 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-call.expect.md
+1 -2
@@ -38,9 +38,8 @@ function Component(props) {
38 const x = t0;
39 const y = useFreeze(x);
40 foo(y, x);
41 - const c_1 = $[1] !== y;
41 let t1;
43 - if (c_1) {
42 + if ($[1] !== y) {
43 t1 = (
44 <Component>
45 {x}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.expect.md
+2 -5
@@ -32,9 +32,8 @@ import { useNoAlias } from "shared-runtime";
32
33 function Component(props) {
34 const $ = useMemoCache(5);
35 - const c_0 = $[0] !== props.a;
35 let t0;
37 - if (c_0) {
36 + if ($[0] !== props.a) {
37 t0 = { a: props.a };
38 $[0] = props.a;
39 $[1] = t0;
@@ -49,10 +48,8 @@ function Component(props) {
48 },
49 [props.a]
50 );
52 - const c_2 = $[2] !== x;
53 - const c_3 = $[3] !== item;
51 let t1;
55 - if (c_2 || c_3) {
52 + if ($[2] !== x || $[3] !== item) {
53 t1 = [x, item];
54 $[2] = x;
55 $[3] = item;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/immutable-hooks.expect.md
+1 -2
@@ -32,9 +32,8 @@ function Component(props) {
32 const y = useFoo(x);
33
34 bar(x, y);
35 - const c_1 = $[1] !== y;
35 let t1;
37 - if (c_1) {
36 + if ($[1] !== y) {
37 t1 = [x, y];
38 $[1] = y;
39 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inadvertent-mutability-readonly-lambda.expect.md
+1 -2
@@ -35,9 +35,8 @@ function Component(props) {
35 const onChange = t0;
36
37 useOtherHook();
38 - const c_1 = $[1] !== onChange;
38 let x;
40 - if (c_1) {
39 + if ($[1] !== onChange) {
40 x = {};
41 foo(x, onChange);
42 $[1] = onChange;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md
+2 -7
@@ -58,12 +58,9 @@ function Foo() {}
58 */
59 function Component(props) {
60 const $ = useMemoCache(8);
61 - const c_0 = $[0] !== props.a;
62 - const c_1 = $[1] !== props.b;
63 - const c_2 = $[2] !== props.c;
61 let a;
62 let b;
66 - if (c_0 || c_1 || c_2) {
63 + if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.c) {
64 a = compute(props.a);
65 b = compute(props.b);
66 if (props.c) {
@@ -79,10 +76,8 @@ function Component(props) {
76 a = $[3];
77 b = $[4];
78 }
82 - const c_5 = $[5] !== a;
83 - const c_6 = $[6] !== b;
79 let t0;
85 - if (c_5 || c_6) {
80 + if ($[5] !== a || $[6] !== b) {
81 t0 = <Foo a={a} b={b} />;
82 $[5] = a;
83 $[6] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/independent.expect.md
+3 -7
@@ -40,9 +40,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
40 */
41 function Component(props) {
42 const $ = useMemoCache(7);
43 - const c_0 = $[0] !== props.a;
43 let t0;
45 - if (c_0) {
44 + if ($[0] !== props.a) {
45 t0 = compute(props.a);
46 $[0] = props.a;
47 $[1] = t0;
@@ -50,9 +49,8 @@ function Component(props) {
49 t0 = $[1];
50 }
51 const a = t0;
53 - const c_2 = $[2] !== props.b;
52 let t1;
55 - if (c_2) {
53 + if ($[2] !== props.b) {
54 t1 = compute(props.b);
55 $[2] = props.b;
56 $[3] = t1;
@@ -60,10 +58,8 @@ function Component(props) {
58 t1 = $[3];
59 }
60 const b = t1;
63 - const c_4 = $[4] !== a;
64 - const c_5 = $[5] !== b;
61 let t2;
66 - if (c_4 || c_5) {
62 + if ($[4] !== a || $[5] !== b) {
63 t2 = <Foo a={a} b={b} />;
64 $[4] = a;
65 $[5] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/independently-memoize-object-property.expect.md
+2 -7
@@ -24,16 +24,11 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function foo(a, b, c) {
26 const $ = useMemoCache(7);
27 - const c_0 = $[0] !== a;
28 - const c_1 = $[1] !== b;
29 - const c_2 = $[2] !== c;
27 let x;
31 - if (c_0 || c_1 || c_2) {
28 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
29 x = { a };
33 - const c_4 = $[4] !== b;
34 - const c_5 = $[5] !== c;
30 let t0;
36 - if (c_4 || c_5) {
31 + if ($[4] !== b || $[5] !== c) {
32 t0 = [b, c];
33 $[4] = b;
34 $[5] = c;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/infer-functions-component-with-hook-call.expect.md
+1 -2
@@ -17,9 +17,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @compilationMo
17 function Component(props) {
18 const $ = useMemoCache(2);
19 const [state] = useState(null);
20 - const c_0 = $[0] !== state;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== state) {
22 t0 = [state];
23 $[0] = state;
24 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/infer-functions-hook-with-hook-call.expect.md
+1 -2
@@ -17,9 +17,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @compilationMo
17 function useStateValue(props) {
18 const $ = useMemoCache(2);
19 const [state] = useState(null);
20 - const c_0 = $[0] !== state;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== state) {
22 t0 = [state];
23 $[0] = state;
24 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md
+2 -4
@@ -36,9 +36,8 @@ import { identity, sum } from "shared-runtime";
36 // global object.
37 function Component(props) {
38 const $ = useMemoCache(4);
39 - const c_0 = $[0] !== props.b;
39 let t0;
41 - if (c_0) {
40 + if ($[0] !== props.b) {
41 t0 = identity(props.b);
42 $[0] = props.b;
43 $[1] = t0;
@@ -51,9 +50,8 @@ function Component(props) {
50 const primitiveVal3 = globalThis.globalThis.NaN;
51
52 sum(primitiveVal1, Infinity, primitiveVal3);
54 - const c_2 = $[2] !== primitiveVal1;
53 let t1;
56 - if (c_2) {
54 + if ($[2] !== primitiveVal1) {
55 t1 = { primitiveVal1, primitiveVal2: Infinity, primitiveVal3 };
56 $[2] = primitiveVal1;
57 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
+4 -11
@@ -27,12 +27,11 @@ function Component(props) {
27 const $ = useMemoCache(15);
28 const item = useFragment(FRAGMENT, props.item);
29 useFreeze(item);
30 - const c_0 = $[0] !== item;
30 let t1;
31 let T2;
32 let t0;
33 let T3;
35 - if (c_0) {
34 + if ($[0] !== item) {
35 const count = new MaybeMutable(item);
36
37 T3 = View;
@@ -55,20 +54,16 @@ function Component(props) {
54 t0 = $[3];
55 T3 = $[4];
56 }
58 - const c_6 = $[6] !== t1;
57 let t4;
60 - if (c_6) {
58 + if ($[6] !== t1) {
59 t4 = <span>{t1}</span>;
60 $[6] = t1;
61 $[7] = t4;
62 } else {
63 t4 = $[7];
64 }
67 - const c_8 = $[8] !== T2;
68 - const c_9 = $[9] !== t0;
69 - const c_10 = $[10] !== t4;
65 let t5;
71 - if (c_8 || c_9 || c_10) {
66 + if ($[8] !== T2 || $[9] !== t0 || $[10] !== t4) {
67 t5 = (
68 <T2>
69 {t0}
@@ -82,10 +77,8 @@ function Component(props) {
77 } else {
78 t5 = $[11];
79 }
85 - const c_12 = $[12] !== T3;
86 - const c_13 = $[13] !== t5;
80 let t6;
88 - if (c_12 || c_13) {
81 + if ($[12] !== T3 || $[13] !== t5) {
82 t6 = <T3>{t5}</T3>;
83 $[12] = T3;
84 $[13] = t5;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md
+2 -7
@@ -47,12 +47,9 @@ function Foo() {}
47 */
48 function Component(props) {
49 const $ = useMemoCache(8);
50 - const c_0 = $[0] !== props.a;
51 - const c_1 = $[1] !== props.b;
52 - const c_2 = $[2] !== props.c;
50 let a;
51 let b;
55 - if (c_0 || c_1 || c_2) {
52 + if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.c) {
53 a = compute(props.a);
54 b = compute(props.b);
55 if (props.c) {
@@ -67,10 +64,8 @@ function Component(props) {
64 a = $[3];
65 b = $[4];
66 }
70 - const c_5 = $[5] !== a;
71 - const c_6 = $[6] !== b;
67 let t0;
73 - if (c_5 || c_6) {
68 + if ($[5] !== a || $[6] !== b) {
69 t0 = <Foo a={a} b={b} />;
70 $[5] = a;
71 $[6] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/interdependent.expect.md
+2 -6
@@ -39,11 +39,9 @@ import { unstable_useMemoCache as useMemoCache } from "react";
39 */
40 function Component(props) {
41 const $ = useMemoCache(7);
42 - const c_0 = $[0] !== props.a;
43 - const c_1 = $[1] !== props.b;
42 let a;
43 let b;
46 - if (c_0 || c_1) {
44 + if ($[0] !== props.a || $[1] !== props.b) {
45 a = compute(props.a);
46 b = compute(props.b);
47 foo(a, b);
@@ -55,10 +53,8 @@ function Component(props) {
53 a = $[2];
54 b = $[3];
55 }
58 - const c_4 = $[4] !== a;
59 - const c_5 = $[5] !== b;
56 let t0;
61 - if (c_4 || c_5) {
57 + if ($[4] !== a || $[5] !== b) {
58 t0 = <Foo a={a} b={b} />;
59 $[4] = a;
60 $[5] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inverted-if.expect.md
+1 -5
@@ -28,12 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function foo(a, b, c, d) {
30 const $ = useMemoCache(5);
31 - const c_0 = $[0] !== a;
32 - const c_1 = $[1] !== b;
33 - const c_2 = $[2] !== c;
34 - const c_3 = $[3] !== d;
31 let y;
36 - if (c_0 || c_1 || c_2 || c_3) {
32 + if ($[0] !== a || $[1] !== b || $[2] !== c || $[3] !== d) {
33 y = [];
34 bb1: if (a) {
35 if (b) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-attribute-with-jsx-element-value.expect.md
+3 -6
@@ -46,9 +46,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
46 function Component(t27) {
47 const $ = useMemoCache(2);
48 const { items } = t27;
49 - const c_0 = $[0] !== items;
49 let t0;
51 - if (c_0) {
50 + if ($[0] !== items) {
51 t0 =
52 items.length > 0 ? (
53 <Foo
@@ -77,9 +76,8 @@ function Foo(t5) {
76 function Bar(t6) {
77 const $ = useMemoCache(2);
78 const { children } = t6;
80 - const c_0 = $[0] !== children;
79 let t0;
82 - if (c_0) {
80 + if ($[0] !== children) {
81 t0 = <div>{children}</div>;
82 $[0] = children;
83 $[1] = t0;
@@ -92,9 +90,8 @@ function Bar(t6) {
90 function Item(t7) {
91 const $ = useMemoCache(2);
92 const { item } = t7;
95 - const c_0 = $[0] !== item.name;
93 let t0;
97 - if (c_0) {
94 + if ($[0] !== item.name) {
95 t0 = <div>{item.name}</div>;
96 $[0] = item.name;
97 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-attribute-with-jsx-fragment-value.flow.expect.md
+2 -4
@@ -33,9 +33,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
33 function Component(t26) {
34 const $ = useMemoCache(2);
35 const { items } = t26;
36 - const c_0 = $[0] !== items;
36 let t0;
38 - if (c_0) {
37 + if ($[0] !== items) {
38 t0 =
39 items.length > 0 ? (
40 <Foo
@@ -59,9 +58,8 @@ function Component(t26) {
58 function Foo(t7) {
59 const $ = useMemoCache(2);
60 const { item } = t7;
62 - const c_0 = $[0] !== item.name;
61 let t0;
64 - if (c_0) {
62 + if ($[0] !== item.name) {
63 t0 = <div>{item.name}</div>;
64 $[0] = item.name;
65 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-empty-expression.expect.md
+1 -2
@@ -25,9 +25,8 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 export function Component(props) {
27 const $ = useMemoCache(2);
28 - const c_0 = $[0] !== props.a;
28 let t0;
30 - if (c_0) {
29 + if ($[0] !== props.a) {
30 t0 = <div>{props.a}</div>;
31 $[0] = props.a;
32 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-fragment.expect.md
+1 -2
@@ -38,9 +38,8 @@ function Foo(props) {
38 } else {
39 t0 = $[0];
40 }
41 - const c_1 = $[1] !== props.greeting;
41 let t1;
43 - if (c_1) {
42 + if ($[1] !== props.greeting) {
43 t1 = (
44 <>
45 Hello {props.greeting} {t0}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-namespaced-name.expect.md
+1 -2
@@ -20,9 +20,8 @@ export const FIXTURE_ENTRYPOINT = {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(2);
23 - const c_0 = $[0] !== props.version;
23 let t0;
25 - if (c_0) {
24 + if ($[0] !== props.version) {
25 t0 = <xml:http protocol:version={props.version} />;
26 $[0] = props.version;
27 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-reactive-local-variable-member-expr.expect.md
+1 -2
@@ -31,9 +31,8 @@ function Component(t13) {
31 const { something } = t13;
32
33 const Foo = something.StaticText1;
34 - const c_0 = $[0] !== Foo;
34 let t0;
36 - if (c_0) {
35 + if ($[0] !== Foo) {
36 t0 = () => <Foo />;
37 $[0] = Foo;
38 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-spread.expect.md
+2 -5
@@ -18,19 +18,16 @@ function Component(props) {
18 const $ = useMemoCache(5);
19
20 const t0 = props.cond ? props.foo : props.bar;
21 - const c_0 = $[0] !== t0;
21 let t1;
23 - if (c_0) {
22 + if ($[0] !== t0) {
23 t1 = { bar: t0 };
24 $[0] = t0;
25 $[1] = t1;
26 } else {
27 t1 = $[1];
28 }
30 - const c_2 = $[2] !== props;
31 - const c_3 = $[3] !== t1;
29 let t2;
33 - if (c_2 || c_3) {
30 + if ($[2] !== props || $[3] !== t1) {
31 t2 = <Component {...props} {...t1} />;
32 $[2] = props;
33 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md
+3 -9
@@ -53,12 +53,10 @@ function maybeMutate(x) {}
53
54 function Component(props) {
55 const $ = useMemoCache(11);
56 - const c_0 = $[0] !== props.component;
57 - const c_1 = $[1] !== props.alternateComponent;
56 let Tag;
57 let T0;
58 let t1;
61 - if (c_0 || c_1) {
59 + if ($[0] !== props.component || $[1] !== props.alternateComponent) {
60 const maybeMutable = new MaybeMutable();
61 Tag = props.component;
62
@@ -74,20 +72,16 @@ function Component(props) {
72 T0 = $[3];
73 t1 = $[4];
74 }
77 - const c_5 = $[5] !== Tag;
75 let t2;
79 - if (c_5) {
76 + if ($[5] !== Tag) {
77 t2 = <Tag />;
78 $[5] = Tag;
79 $[6] = t2;
80 } else {
81 t2 = $[6];
82 }
86 - const c_7 = $[7] !== T0;
87 - const c_8 = $[8] !== t1;
88 - const c_9 = $[9] !== t2;
83 let t3;
90 - if (c_7 || c_8 || c_9) {
84 + if ($[7] !== T0 || $[8] !== t1 || $[9] !== t2) {
85 t3 = (
86 <T0>
87 {t1}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md
+1 -2
@@ -39,9 +39,8 @@ function Component(props) {
39 } else {
40 t0 = $[0];
41 }
42 - const c_1 = $[1] !== t1;
42 let t2;
44 - if (c_1) {
43 + if ($[1] !== t1) {
44 t2 = (
45 <StaticText1>
46 {t1}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-ternary-local-variable.expect.md
+1 -2
@@ -26,9 +26,8 @@ import { RenderPropAsChild, StaticText1, StaticText2 } from "shared-runtime";
26 function Component(props) {
27 const $ = useMemoCache(2);
28 const Foo = props.showText1 ? StaticText1 : StaticText2;
29 - const c_0 = $[0] !== Foo;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== Foo) {
31 t0 = <RenderPropAsChild items={[() => <Foo key="0" />]} />;
32 $[0] = Foo;
33 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md
+2 -5
@@ -34,9 +34,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Here, element
34 // them to reads
35 function CaptureNotMutate(props) {
36 const $ = useMemoCache(5);
37 - const c_0 = $[0] !== props.x;
37 let t0;
39 - if (c_0) {
38 + if ($[0] !== props.x) {
39 t0 = foo(props.x);
40 $[0] = props.x;
41 $[1] = t0;
@@ -44,10 +43,8 @@ function CaptureNotMutate(props) {
43 t0 = $[1];
44 }
45 const idx = t0;
47 - const c_2 = $[2] !== props.el;
48 - const c_3 = $[3] !== idx;
46 let aliasedElement;
50 - if (c_2 || c_3) {
47 + if ($[2] !== props.el || $[3] !== idx) {
48 const element = bar(props.el);
49
50 const fn = function () {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/lambda-mutated-non-reactive-to-reactive.expect.md
+2 -4
@@ -24,9 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function f(a) {
26 const $ = useMemoCache(4);
27 - const c_0 = $[0] !== a;
27 let x;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 x;
30 x = { a };
31 $[0] = a;
@@ -36,9 +35,8 @@ function f(a) {
35 }
36
37 const t0 = x;
39 - const c_2 = $[2] !== t0;
38 let t1;
41 - if (c_2) {
39 + if ($[2] !== t0) {
40 t1 = <div x={t0} />;
41 $[2] = t0;
42 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/logical-expression-object.expect.md
+1 -3
@@ -30,10 +30,8 @@ function component(props) {
30
31 const a = props.a || (props.b && props.c && props.d);
32 const b = (props.a && props.b && props.c) || props.d;
33 - const c_0 = $[0] !== a;
34 - const c_1 = $[1] !== b;
33 let t0;
36 - if (c_0 || c_1) {
34 + if ($[0] !== a || $[1] !== b) {
35 t0 = { a, b };
36 $[0] = a;
37 $[1] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/maybe-mutate-object-in-callback.expect.md
+1 -2
@@ -51,9 +51,8 @@ function Component(props) {
51 t1 = $[1];
52 }
53 const onClick = t1;
54 - const c_2 = $[2] !== props.children;
54 let t2;
56 - if (c_2) {
55 + if ($[2] !== props.children) {
56 t2 = <Foo callback={onClick}>{props.children}</Foo>;
57 $[2] = props.children;
58 $[3] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/merge-consecutive-scopes-objects.expect.md
+4 -9
@@ -48,18 +48,16 @@ function Component(props) {
48 } else {
49 t0 = $[0];
50 }
51 - const c_1 = $[1] !== state;
51 let t1;
53 - if (c_1) {
52 + if ($[1] !== state) {
53 t1 = { component: "span", props: { children: [state] } };
54 $[1] = state;
55 $[2] = t1;
56 } else {
57 t1 = $[2];
58 }
60 - const c_3 = $[3] !== state;
59 let t2;
62 - if (c_3) {
60 + if ($[3] !== state) {
61 t2 = () => setState(state + 1);
62 $[3] = state;
63 $[4] = t2;
@@ -73,9 +71,8 @@ function Component(props) {
71 } else {
72 t3 = $[5];
73 }
76 - const c_6 = $[6] !== t2;
74 let t4;
78 - if (c_6) {
75 + if ($[6] !== t2) {
76 t4 = {
77 component: "button",
78 props: { "data-testid": "button", onClick: t2, children: t3 },
@@ -85,10 +82,8 @@ function Component(props) {
82 } else {
83 t4 = $[7];
84 }
88 - const c_8 = $[8] !== t1;
89 - const c_9 = $[9] !== t4;
85 let t5;
91 - if (c_8 || c_9) {
86 + if ($[8] !== t1 || $[9] !== t4) {
87 t5 = [t0, t1, t4];
88 $[8] = t1;
89 $[9] = t4;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/merge-consecutive-scopes.expect.md
+3 -7
@@ -37,18 +37,16 @@ function Component() {
37 } else {
38 t0 = $[0];
39 }
40 - const c_1 = $[1] !== state;
40 let t1;
42 - if (c_1) {
41 + if ($[1] !== state) {
42 t1 = <span>{state}</span>;
43 $[1] = state;
44 $[2] = t1;
45 } else {
46 t1 = $[2];
47 }
49 - const c_3 = $[3] !== state;
48 let t2;
51 - if (c_3) {
49 + if ($[3] !== state) {
50 t2 = (
51 <button data-testid="button" onClick={() => setState(state + 1)}>
52 increment
@@ -59,10 +57,8 @@ function Component() {
57 } else {
58 t2 = $[4];
59 }
62 - const c_5 = $[5] !== t1;
63 - const c_6 = $[6] !== t2;
60 let t3;
65 - if (c_5 || c_6) {
61 + if ($[5] !== t1 || $[6] !== t2) {
62 t3 = (
63 <div>
64 {t0}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/merge-nested-scopes-with-same-inputs.expect.md
+1 -2
@@ -32,9 +32,8 @@ export const FIXTURE_ENTRYPOINT = {
32 import { unstable_useMemoCache as useMemoCache } from "react"; // @enableMergeConsecutiveScopes
33 function Component(props) {
34 const $ = useMemoCache(2);
35 - const c_0 = $[0] !== props.a;
35 let y;
37 - if (c_0) {
36 + if ($[0] !== props.a) {
37 y = {};
38
39 const x = {};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/method-call-computed.expect.md
+3 -8
@@ -24,9 +24,8 @@ function foo(a, b, c) {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function foo(a, b, c) {
26 const $ = useMemoCache(8);
27 - const c_0 = $[0] !== a;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 t0 = makeObject(a);
30 $[0] = a;
31 $[1] = t0;
@@ -34,9 +33,8 @@ function foo(a, b, c) {
33 t0 = $[1];
34 }
35 const x = t0;
37 - const c_2 = $[2] !== a;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== a) {
38 t1 = makeObject(a);
39 $[2] = a;
40 $[3] = t1;
@@ -44,11 +42,8 @@ function foo(a, b, c) {
42 t1 = $[3];
43 }
44 const y = t1;
47 - const c_4 = $[4] !== x;
48 - const c_5 = $[5] !== y.method;
49 - const c_6 = $[6] !== b;
45 let t2;
51 - if (c_4 || c_5 || c_6) {
46 + if ($[4] !== x || $[5] !== y.method || $[6] !== b) {
47 t2 = x[y.method](b);
48 $[4] = x;
49 $[5] = y.method;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/method-call-fn-call.expect.md
+2 -6
@@ -21,9 +21,8 @@ function foo(a, b, c) {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function foo(a, b, c) {
23 const $ = useMemoCache(6);
24 - const c_0 = $[0] !== a;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 t0 = makeObject(a);
27 $[0] = a;
28 $[1] = t0;
@@ -33,11 +32,8 @@ function foo(a, b, c) {
32 const x = t0;
33
34 const method = x.method;
36 - const c_2 = $[2] !== method;
37 - const c_3 = $[3] !== x;
38 - const c_4 = $[4] !== b;
35 let t1;
40 - if (c_2 || c_3 || c_4) {
36 + if ($[2] !== method || $[3] !== x || $[4] !== b) {
37 t1 = method.call(x, b);
38 $[2] = method;
39 $[3] = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/method-call.expect.md
+2 -5
@@ -30,9 +30,8 @@ import { addOne, shallowCopy } from "shared-runtime";
30
31 function foo(a, b, c) {
32 const $ = useMemoCache(5);
33 - const c_0 = $[0] !== a;
33 let t0;
35 - if (c_0) {
34 + if ($[0] !== a) {
35 t0 = shallowCopy(a);
36 $[0] = a;
37 $[1] = t0;
@@ -40,10 +39,8 @@ function foo(a, b, c) {
39 t0 = $[1];
40 }
41 const x = t0;
43 - const c_2 = $[2] !== x;
44 - const c_3 = $[3] !== b;
42 let t1;
46 - if (c_2 || c_3) {
43 + if ($[2] !== x || $[3] !== b) {
44 t1 = x.foo(b);
45 $[2] = x;
46 $[3] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-default-gating-test.expect.md
+1 -2
@@ -22,9 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
22 const ErrorView = isForgetEnabled_Fixtures()
23 ? (error, _retry) => {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== error;
25 let t0;
27 - if (c_0) {
26 + if ($[0] !== error) {
27 t0 = <MessageBox error={error} />;
28 $[0] = error;
29 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.expect.md
+1 -2
@@ -22,9 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
22 const ErrorView = isForgetEnabled_Fixtures()
23 ? (error, _retry) => {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== error;
25 let t0;
27 - if (c_0) {
26 + if ($[0] !== error) {
27 t0 = <MessageBox error={error} />;
28 $[0] = error;
29 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.expect.md
+1 -2
@@ -24,9 +24,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
24 const ErrorView = isForgetEnabled_Fixtures()
25 ? (error, _retry) => {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== error;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== error) {
29 t0 = <MessageBox error={error} />;
30 $[0] = error;
31 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-shadowed-identifiers.expect.md
+1 -3
@@ -38,10 +38,8 @@ function Component(props) {
38 t0 = $[0];
39 }
40 const onChange = t0;
41 - const c_1 = $[1] !== x;
42 - const c_2 = $[2] !== onChange;
41 let t1;
44 - if (c_1 || c_2) {
42 + if ($[1] !== x || $[2] !== onChange) {
43 t1 = <input value={x} onChange={onChange} />;
44 $[1] = x;
45 $[2] = onChange;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-optional-member-expr.expect.md
+1 -2
@@ -19,9 +19,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // We should code
19 function Component(props) {
20 const $ = useMemoCache(2);
21 const t0 = props.a?.b.c.d;
22 - const c_0 = $[0] !== t0;
22 let t1;
24 - if (c_0) {
23 + if ($[0] !== t0) {
24 t1 = foo(t0);
25 $[0] = t0;
26 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/new-spread.expect.md
+1 -3
@@ -15,10 +15,8 @@ function Component(props) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(3);
18 - const c_0 = $[0] !== props.bar;
19 - const c_1 = $[1] !== props.foo;
18 let t0;
21 - if (c_0 || c_1) {
19 + if ($[0] !== props.bar || $[1] !== props.foo) {
20 t0 = new Foo(...props.foo, null, ...[props.bar]);
21 $[0] = props.bar;
22 $[1] = props.foo;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/noAlias-filter-on-array-prop.expect.md
+1 -2
@@ -34,9 +34,8 @@ export const FIXTURE_ENTRYPOINT = {
34 import { unstable_useMemoCache as useMemoCache } from "react";
35 function Component(props) {
36 const $ = useMemoCache(3);
37 - const c_0 = $[0] !== props.items;
37 let t1;
39 - if (c_0) {
38 + if ($[0] !== props.items) {
39 let t0;
40 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
41 t0 = (item) => item != null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md
+2 -4
@@ -23,9 +23,8 @@ function foo(a, b, c, d) {
23 const $ = useMemoCache(4);
24 let x = undefined;
25 if (someVal) {
26 - const c_0 = $[0] !== b;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== b) {
28 t0 = { b };
29 $[0] = b;
30 $[1] = t0;
@@ -34,9 +33,8 @@ function foo(a, b, c, d) {
33 }
34 x = t0;
35 } else {
37 - const c_2 = $[2] !== c;
36 let t1;
39 - if (c_2) {
37 + if ($[2] !== c) {
38 t1 = { c };
39 $[2] = c;
40 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-mutated-after-if-else.expect.md
+1 -3
@@ -22,10 +22,8 @@ function foo(a, b, c, d) {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function foo(a, b, c, d) {
24 const $ = useMemoCache(3);
25 - const c_0 = $[0] !== b;
26 - const c_1 = $[1] !== c;
25 let x;
28 - if (c_0 || c_1) {
26 + if ($[0] !== b || $[1] !== c) {
27 x = undefined;
28 if (someVal) {
29 x = { b };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else-with-alias.expect.md
+1 -2
@@ -25,9 +25,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
25 function foo(a, b, c, d) {
26 const $ = useMemoCache(2);
27 someObj();
28 - const c_0 = $[0] !== a;
28 let x;
30 - if (c_0) {
29 + if ($[0] !== a) {
30 x = undefined;
31 if (a) {
32 const y = someObj();
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else.expect.md
+1 -2
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
23 function foo(a, b, c, d) {
24 const $ = useMemoCache(2);
25 someObj();
26 - const c_0 = $[0] !== a;
26 let x;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 x = undefined;
29 if (a) {
30 x = someObj();
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-mutated-after-nested-if-else-with-alias.expect.md
+1 -3
@@ -31,10 +31,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
31 function foo(a, b, c, d) {
32 const $ = useMemoCache(3);
33 someObj();
34 - const c_0 = $[0] !== a;
35 - const c_1 = $[1] !== b;
34 let x;
37 - if (c_0 || c_1) {
35 + if ($[0] !== a || $[1] !== b) {
36 x = undefined;
37 if (a) {
38 let z = undefined;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-expression-string-literal-key.expect.md
+1 -2
@@ -21,9 +21,8 @@ export const FIXTURE_ENTRYPOINT = {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== props.foo;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== props.foo) {
26 t0 = { foo: props.foo };
27 $[0] = props.foo;
28 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-literal-spread-element.expect.md
+1 -2
@@ -21,9 +21,8 @@ export const FIXTURE_ENTRYPOINT = {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function Component(props) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== props.foo;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== props.foo) {
26 t0 = { ...props.foo };
27 $[0] = props.foo;
28 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md
+3 -7
@@ -23,9 +23,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
23 function component(t16) {
24 const $ = useMemoCache(7);
25 const { a, b } = t16;
26 - const c_0 = $[0] !== a;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 t0 = { a };
29 $[0] = a;
30 $[1] = t0;
@@ -33,9 +32,8 @@ function component(t16) {
32 t0 = $[1];
33 }
34 const y = t0;
36 - const c_2 = $[2] !== b;
35 let t1;
38 - if (c_2) {
36 + if ($[2] !== b) {
37 t1 = { b };
38 $[2] = b;
39 $[3] = t1;
@@ -43,10 +41,8 @@ function component(t16) {
41 t1 = $[3];
42 }
43 const z = t1;
46 - const c_4 = $[4] !== y;
47 - const c_5 = $[5] !== z;
44 let t2;
49 - if (c_4 || c_5) {
45 + if ($[4] !== y || $[5] !== z) {
46 t2 = { y, z };
47 $[4] = y;
48 $[5] = z;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-1.expect.md
+2 -4
@@ -28,9 +28,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @debug
28 function Component(t16) {
29 const $ = useMemoCache(4);
30 const { a, b } = t16;
31 - const c_0 = $[0] !== a;
31 let t0;
33 - if (c_0) {
32 + if ($[0] !== a) {
33 t0 = function () {
34 return [a];
35 };
@@ -39,9 +38,8 @@ function Component(t16) {
38 } else {
39 t0 = $[1];
40 }
42 - const c_2 = $[2] !== t0;
41 let t1;
44 - if (c_2) {
42 + if ($[2] !== t0) {
43 t1 = {
44 x: t0,
45 y() {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md
+3 -7
@@ -26,28 +26,24 @@ import { unstable_useMemoCache as useMemoCache } from "react";
26 function Component(t16) {
27 const $ = useMemoCache(7);
28 const { a, b, c } = t16;
29 - const c_0 = $[0] !== a;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== a) {
31 t0 = [a];
32 $[0] = a;
33 $[1] = t0;
34 } else {
35 t0 = $[1];
36 }
38 - const c_2 = $[2] !== c;
37 let t1;
40 - if (c_2) {
38 + if ($[2] !== c) {
39 t1 = { c };
40 $[2] = c;
41 $[3] = t1;
42 } else {
43 t1 = $[3];
44 }
47 - const c_4 = $[4] !== t0;
48 - const c_5 = $[5] !== t1;
45 let t2;
50 - if (c_4 || c_5) {
46 + if ($[4] !== t0 || $[5] !== t1) {
47 t2 = {
48 x: t0,
49 y() {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-chained.expect.md
+1 -2
@@ -14,9 +14,8 @@ function Component(props) {
14 import { unstable_useMemoCache as useMemoCache } from "react";
15 function Component(props) {
16 const $ = useMemoCache(2);
17 - const c_0 = $[0] !== props;
17 let t0;
19 - if (c_0) {
18 + if ($[0] !== props) {
19 t0 = call?.(props.a)?.(props.b)?.(props.c);
20 $[0] = props;
21 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-logical.expect.md
+1 -2
@@ -16,9 +16,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(2);
18 const item = useFragment(graphql`...`, props.item);
19 - const c_0 = $[0] !== item.items;
19 let t0;
21 - if (c_0) {
20 + if ($[0] !== item.items) {
21 t0 = item.items?.map((item_0) => renderItem(item_0)) ?? [];
22 $[0] = item.items;
23 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-simple.expect.md
+1 -2
@@ -14,9 +14,8 @@ function Component(props) {
14 import { unstable_useMemoCache as useMemoCache } from "react";
15 function Component(props) {
16 const $ = useMemoCache(2);
17 - const c_0 = $[0] !== props;
17 let t0;
19 - if (c_0) {
18 + if ($[0] !== props) {
19 t0 = foo?.(props);
20 $[0] = props;
21 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md
+1 -2
@@ -24,9 +24,8 @@ function Component(props) {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== props;
27 let t0;
29 - if (c_0) {
28 + if ($[0] !== props) {
29 const x = makeOptionalFunction(props);
30
31 t0 = x?.(
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-with-optional-property-load.expect.md
+1 -2
@@ -14,9 +14,8 @@ function Component(props) {
14 import { unstable_useMemoCache as useMemoCache } from "react";
15 function Component(props) {
16 const $ = useMemoCache(2);
17 - const c_0 = $[0] !== props;
17 let t0;
19 - if (c_0) {
18 + if ($[0] !== props) {
19 t0 = props?.items?.map?.(render)?.filter(Boolean) ?? [];
20 $[0] = props;
21 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call.expect.md
+1 -2
@@ -17,9 +17,8 @@ function Component(props) {
17 import { unstable_useMemoCache as useMemoCache } from "react";
18 function Component(props) {
19 const $ = useMemoCache(2);
20 - const c_0 = $[0] !== props;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== props) {
22 const x = makeOptionalFunction(props);
23 const y = makeObject(props);
24 t0 = x?.(y.a, props.a, foo(y.b), bar(props.b));
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-computed-member-expression.expect.md
+2 -5
@@ -15,9 +15,8 @@ function Component(props) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(5);
18 - const c_0 = $[0] !== props;
18 let t0;
20 - if (c_0) {
19 + if ($[0] !== props) {
20 t0 = makeObject(props);
21 $[0] = props;
22 $[1] = t0;
@@ -25,10 +24,8 @@ function Component(props) {
24 t0 = $[1];
25 }
26 const object = t0;
28 - const c_2 = $[2] !== object;
29 - const c_3 = $[3] !== props;
27 let t1;
31 - if (c_2 || c_3) {
28 + if ($[2] !== object || $[3] !== props) {
29 t1 = object?.[props.key];
30 $[2] = object;
31 $[3] = props;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-member-expression-call-as-property.expect.md
+1 -3
@@ -23,10 +23,8 @@ function Component(props) {
23 t0 = $[0];
24 }
25 const x = t0;
26 - const c_1 = $[1] !== props;
27 - const c_2 = $[2] !== x;
26 let t1;
29 - if (c_1 || c_2) {
27 + if ($[1] !== props || $[2] !== x) {
28 t1 = x?.[foo(props.value)];
29 $[1] = props;
30 $[2] = x;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-member-expression-chain.expect.md
+1 -3
@@ -27,10 +27,8 @@ function Component(props) {
27 const $ = useMemoCache(3);
28 const x = props?.b.c;
29 const y = props?.b.c.d?.e.f.g?.h;
30 - const c_0 = $[0] !== x;
31 - const c_1 = $[1] !== y;
30 let t0;
33 - if (c_0 || c_1) {
31 + if ($[0] !== x || $[1] !== y) {
32 t0 = { x, y };
33 $[0] = x;
34 $[1] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-member-expression-with-optional-member-expr-as-property.expect.md
+1 -3
@@ -23,10 +23,8 @@ function Component(props) {
23 t0 = $[0];
24 }
25 const x = t0;
26 - const c_1 = $[1] !== x.y;
27 - const c_2 = $[2] !== props;
26 let t1;
29 - if (c_1 || c_2) {
27 + if ($[1] !== x.y || $[2] !== props) {
28 t1 = x.y?.[props.a?.[props.b?.[props.c]]];
29 $[1] = x.y;
30 $[2] = props;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-method-call.expect.md
+1 -2
@@ -17,9 +17,8 @@ function Component(props) {
17 import { unstable_useMemoCache as useMemoCache } from "react";
18 function Component(props) {
19 const $ = useMemoCache(2);
20 - const c_0 = $[0] !== props;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== props) {
22 const x = makeObject(props);
23 const y = makeObject(props);
24 t0 = x.optionalMethod?.(y.a, props.a, foo(y.b), bar(props.b));
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-receiver-method-call.expect.md
+1 -2
@@ -17,9 +17,8 @@ function Component(props) {
17 import { unstable_useMemoCache as useMemoCache } from "react";
18 function Component(props) {
19 const $ = useMemoCache(2);
20 - const c_0 = $[0] !== props;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== props) {
22 const x = makeOptionalObject(props);
23 const y = makeObject(props);
24 t0 = x?.method(y.a, props.a, foo(y.b), bar(props.b));
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-receiver-optional-method.expect.md
+1 -2
@@ -17,9 +17,8 @@ function Component(props) {
17 import { unstable_useMemoCache as useMemoCache } from "react";
18 function Component(props) {
19 const $ = useMemoCache(2);
20 - const c_0 = $[0] !== props;
20 let t0;
22 - if (c_0) {
21 + if ($[0] !== props) {
22 const x = makeOptionalObject(props);
23 const y = makeObject(props);
24 t0 = x?.optionalMethod?.(y.a, props.a, foo(y.b), bar(props.b));
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowing-within-block.expect.md
+3 -9
@@ -29,17 +29,12 @@ export const FIXTURE_ENTRYPOINT = {
29 import { unstable_useMemoCache as useMemoCache } from "react";
30 function foo(a, b, c) {
31 const $ = useMemoCache(9);
32 - const c_0 = $[0] !== a;
33 - const c_1 = $[1] !== b;
34 - const c_2 = $[2] !== c;
32 let x;
36 - if (c_0 || c_1 || c_2) {
33 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
34 x = [];
35 if (a) {
39 - const c_4 = $[4] !== b;
40 - const c_5 = $[5] !== c;
36 let y;
42 - if (c_4 || c_5) {
37 + if ($[4] !== b || $[5] !== c) {
38 y = [];
39 if (b) {
40 y.push(c);
@@ -50,9 +45,8 @@ function foo(a, b, c) {
45 } else {
46 y = $[6];
47 }
53 - const c_7 = $[7] !== y;
48 let t0;
55 - if (c_7) {
49 + if ($[7] !== y) {
50 t0 = <div>{y}</div>;
51 $[7] = y;
52 $[8] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/overlapping-scopes-within-block.expect.md
+2 -7
@@ -29,17 +29,12 @@ export const FIXTURE_ENTRYPOINT = {
29 import { unstable_useMemoCache as useMemoCache } from "react";
30 function foo(a, b, c) {
31 const $ = useMemoCache(7);
32 - const c_0 = $[0] !== a;
33 - const c_1 = $[1] !== b;
34 - const c_2 = $[2] !== c;
32 let x;
36 - if (c_0 || c_1 || c_2) {
33 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
34 x = [];
35 if (a) {
39 - const c_4 = $[4] !== b;
40 - const c_5 = $[5] !== c;
36 let y;
42 - if (c_4 || c_5) {
37 + if ($[4] !== b || $[5] !== c) {
38 y = [];
39 if (b) {
40 y.push(c);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/phi-type-inference-array-push.expect.md
+2 -5
@@ -33,10 +33,9 @@ export const FIXTURE_ENTRYPOINT = {
33 import { unstable_useMemoCache as useMemoCache } from "react"; // @debug
34 function Component(props) {
35 const $ = useMemoCache(6);
36 - const c_0 = $[0] !== props;
36 let x;
37 let y;
39 - if (c_0) {
38 + if ($[0] !== props) {
39 x = {};
40 y = undefined;
41 if (props.cond) {
@@ -53,10 +52,8 @@ function Component(props) {
52 x = $[1];
53 y = $[2];
54 }
56 - const c_3 = $[3] !== x;
57 - const c_4 = $[4] !== y;
55 let t0;
59 - if (c_3 || c_4) {
56 + if ($[3] !== x || $[4] !== y) {
57 t0 = [x, y];
58 $[3] = x;
59 $[4] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/phi-type-inference-property-store.expect.md
+2 -6
@@ -41,10 +41,8 @@ function Component(props) {
41 t0 = $[0];
42 }
43 const x = t0;
44 - const c_1 = $[1] !== props;
45 - const c_2 = $[2] !== x;
44 let y;
47 - if (c_1 || c_2) {
45 + if ($[1] !== props || $[2] !== x) {
46 y = undefined;
47 if (props.cond) {
48 y = {};
@@ -59,10 +57,8 @@ function Component(props) {
57 } else {
58 y = $[3];
59 }
62 - const c_4 = $[4] !== x;
63 - const c_5 = $[5] !== y;
60 let t1;
65 - if (c_4 || c_5) {
61 + if ($[4] !== x || $[5] !== y) {
62 t1 = [x, y];
63 $[4] = x;
64 $[5] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md
+3 -8
@@ -27,17 +27,14 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.b + 1 is
27 // y depends on either props.b or props.b + 1
28 function PrimitiveAsDepNested(props) {
29 const $ = useMemoCache(9);
30 - const c_0 = $[0] !== props.b;
31 - const c_1 = $[1] !== props.a;
30 let x;
31 let y;
34 - if (c_0 || c_1) {
32 + if ($[0] !== props.b || $[1] !== props.a) {
33 x = {};
34 mutate(x);
35 const t0 = props.b + 1;
38 - const c_4 = $[4] !== t0;
36 let t1;
40 - if (c_4) {
37 + if ($[4] !== t0) {
38 t1 = foo(t0);
39 $[4] = t0;
40 $[5] = t1;
@@ -54,10 +51,8 @@ function PrimitiveAsDepNested(props) {
51 x = $[2];
52 y = $[3];
53 }
57 - const c_6 = $[6] !== x;
58 - const c_7 = $[7] !== y;
54 let t2;
60 - if (c_6 || c_7) {
55 + if ($[6] !== x || $[7] !== y) {
56 t2 = [x, y];
57 $[6] = x;
58 $[7] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep.expect.md
+1 -2
@@ -25,9 +25,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.b + 1 is
25 function PrimitiveAsDep(props) {
26 const $ = useMemoCache(2);
27 const t0 = props.b + 1;
28 - const c_0 = $[0] !== t0;
28 let t1;
30 - if (c_0) {
29 + if ($[0] !== t0) {
30 t1 = foo(t0);
31 $[0] = t0;
32 $[1] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/prop-capturing-function-1.expect.md
+2 -5
@@ -24,10 +24,8 @@ export const FIXTURE_ENTRYPOINT = {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function component(a, b) {
26 const $ = useMemoCache(5);
27 - const c_0 = $[0] !== a;
28 - const c_1 = $[1] !== b;
27 let t0;
30 - if (c_0 || c_1) {
28 + if ($[0] !== a || $[1] !== b) {
29 t0 = { a, b };
30 $[0] = a;
31 $[1] = b;
@@ -36,9 +34,8 @@ function component(a, b) {
34 t0 = $[2];
35 }
36 const z = t0;
39 - const c_3 = $[3] !== z;
37 let t1;
41 - if (c_3) {
38 + if ($[3] !== z) {
39 t1 = function () {
40 console.log(z);
41 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/property-assignment.expect.md
+2 -5
@@ -19,10 +19,9 @@ function Component(props) {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(props) {
21 const $ = useMemoCache(6);
22 - const c_0 = $[0] !== props.p0;
22 let x;
23 let child;
25 - if (c_0) {
24 + if ($[0] !== props.p0) {
25 x = {};
26 const y = [];
27 x.y = y;
@@ -35,10 +34,8 @@ function Component(props) {
34 x = $[1];
35 child = $[2];
36 }
38 - const c_3 = $[3] !== x;
39 - const c_4 = $[4] !== child;
37 let t0;
41 - if (c_3 || c_4) {
38 + if ($[3] !== x || $[4] !== child) {
39 t0 = <Component data={x}>{child}</Component>;
40 $[3] = x;
41 $[4] = child;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/property-call-spread.expect.md
+1 -3
@@ -15,10 +15,8 @@ function Component(props) {
15 import { unstable_useMemoCache as useMemoCache } from "react";
16 function Component(props) {
17 const $ = useMemoCache(3);
18 - const c_0 = $[0] !== props.a;
19 - const c_1 = $[1] !== props.b;
18 let t0;
21 - if (c_0 || c_1) {
19 + if ($[0] !== props.a || $[1] !== props.b) {
20 t0 = foo.bar(...props.a, null, ...props.b);
21 $[0] = props.a;
22 $[1] = props.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/react-namespace.expect.md
+2 -5
@@ -39,19 +39,16 @@ function Component(props) {
39 ref.current = true;
40 foo.current = true;
41 };
42 - const c_0 = $[0] !== props.children;
42 let t0;
44 - if (c_0) {
43 + if ($[0] !== props.children) {
44 t0 = React.cloneElement(props.children);
45 $[0] = props.children;
46 $[1] = t0;
47 } else {
48 t0 = $[1];
49 }
51 - const c_2 = $[2] !== onClick;
52 - const c_3 = $[3] !== t0;
50 let t1;
54 - if (c_2 || c_3) {
51 + if ($[2] !== onClick || $[3] !== t0) {
52 t1 = <div onClick={onClick}>{t0}</div>;
53 $[2] = onClick;
54 $[3] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactive-dependencies-non-optional-properties-inside-optional-chain.expect.md
+1 -2
@@ -14,9 +14,8 @@ function Component(props) {
14 import { unstable_useMemoCache as useMemoCache } from "react";
15 function Component(props) {
16 const $ = useMemoCache(2);
17 - const c_0 = $[0] !== props.post.feedback.comments;
17 let t0;
19 - if (c_0) {
18 + if ($[0] !== props.post.feedback.comments) {
19 t0 = props.post.feedback.comments?.edges?.map(render);
20 $[0] = props.post.feedback.comments;
21 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactive-scopes-if.expect.md
+3 -8
@@ -28,16 +28,12 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function foo(a, b, c) {
30 const $ = useMemoCache(8);
31 - const c_0 = $[0] !== a;
32 - const c_1 = $[1] !== b;
33 - const c_2 = $[2] !== c;
31 let x;
35 - if (c_0 || c_1 || c_2) {
32 + if ($[0] !== a || $[1] !== b || $[2] !== c) {
33 x = [];
34 if (a) {
38 - const c_4 = $[4] !== b;
35 let y;
40 - if (c_4) {
36 + if ($[4] !== b) {
37 y = [];
38 y.push(b);
39 $[4] = b;
@@ -45,9 +41,8 @@ function foo(a, b, c) {
41 } else {
42 y = $[5];
43 }
48 - const c_6 = $[6] !== y;
44 let t0;
50 - if (c_6) {
45 + if ($[6] !== y) {
46 t0 = <div>{y}</div>;
47 $[6] = y;
48 $[7] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactive-scopes.expect.md
+2 -5
@@ -27,10 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function f(a, b) {
29 const $ = useMemoCache(5);
30 - const c_0 = $[0] !== a.length;
31 - const c_1 = $[1] !== b;
30 let x;
33 - if (c_0 || c_1) {
31 + if ($[0] !== a.length || $[1] !== b) {
32 x = [];
33 if (a.length === 1) {
34 if (b) {
@@ -43,9 +41,8 @@ function f(a, b) {
41 } else {
42 x = $[2];
43 }
46 - const c_3 = $[3] !== x;
44 let t0;
48 - if (c_3) {
45 + if ($[3] !== x) {
46 t0 = <div>{x}</div>;
47 $[3] = x;
48 $[4] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md
+3 -6
@@ -36,9 +36,8 @@ export const FIXTURE_ENTRYPOINT = {
36 import { unstable_useMemoCache as useMemoCache } from "react";
37 function Component(props) {
38 const $ = useMemoCache(6);
39 - const c_0 = $[0] !== props.b;
39 let a;
41 - if (c_0) {
40 + if ($[0] !== props.b) {
41 a = {};
42 const b = [];
43 b.push(props.b);
@@ -48,9 +47,8 @@ function Component(props) {
47 } else {
48 a = $[1];
49 }
51 - const c_2 = $[2] !== a;
50 let t0;
53 - if (c_2) {
51 + if ($[2] !== a) {
52 t0 = [a];
53 $[2] = a;
54 $[3] = t0;
@@ -58,9 +56,8 @@ function Component(props) {
56 t0 = $[3];
57 }
58 const c = t0;
61 - const c_4 = $[4] !== a;
59 let t1;
63 - if (c_4) {
60 + if ($[4] !== a) {
61 t1 = [c, a];
62 $[4] = a;
63 $[5] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-computed-load.expect.md
+3 -8
@@ -19,10 +19,8 @@ function Component(props) {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(props) {
21 const $ = useMemoCache(8);
22 - const c_0 = $[0] !== props.key;
23 - const c_1 = $[1] !== props.a;
22 let items;
25 - if (c_0 || c_1) {
23 + if ($[0] !== props.key || $[1] !== props.a) {
24 items = bar();
25 mutate(items[props.key], props.a);
26 $[0] = props.key;
@@ -33,9 +31,8 @@ function Component(props) {
31 }
32
33 const t0 = items.length + 1;
36 - const c_3 = $[3] !== t0;
34 let t1;
38 - if (c_3) {
35 + if ($[3] !== t0) {
36 t1 = foo(t0);
37 $[3] = t0;
38 $[4] = t1;
@@ -43,10 +40,8 @@ function Component(props) {
40 t1 = $[4];
41 }
42 const count = t1;
46 - const c_5 = $[5] !== items;
47 - const c_6 = $[6] !== count;
43 let t2;
49 - if (c_5 || c_6) {
44 + if ($[5] !== items || $[6] !== count) {
45 t2 = { items, count };
46 $[5] = items;
47 $[6] = count;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-property-load.expect.md
+3 -7
@@ -19,9 +19,8 @@ function Component(props) {
19 import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(props) {
21 const $ = useMemoCache(7);
22 - const c_0 = $[0] !== props.a;
22 let items;
24 - if (c_0) {
23 + if ($[0] !== props.a) {
24 items = bar();
25 mutate(items.a, props.a);
26 $[0] = props.a;
@@ -31,9 +30,8 @@ function Component(props) {
30 }
31
32 const t0 = items.length + 1;
34 - const c_2 = $[2] !== t0;
33 let t1;
36 - if (c_2) {
34 + if ($[2] !== t0) {
35 t1 = foo(t0);
36 $[2] = t0;
37 $[3] = t1;
@@ -41,10 +39,8 @@ function Component(props) {
39 t1 = $[3];
40 }
41 const count = t1;
44 - const c_4 = $[4] !== items;
45 - const c_5 = $[5] !== count;
42 let t2;
47 - if (c_4 || c_5) {
43 + if ($[4] !== items || $[5] !== count) {
44 t2 = { items, count };
45 $[4] = items;
46 $[5] = count;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.expect.md
+1 -2
@@ -45,9 +45,8 @@ function Component(props) {
45 posts.push(t0);
46 const count = posts.length;
47 foo(count);
48 - const c_1 = $[1] !== posts;
48 let t1;
50 - if (c_1) {
49 + if ($[1] !== posts) {
50 t1 = <>{posts}</>;
51 $[1] = posts;
52 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md
+2 -4
@@ -28,9 +28,8 @@ function Component(props) {
28 graphql`fragment Component_user on User { ... }`,
29 props.user
30 );
31 - const c_0 = $[0] !== user.timeline.posts.edges.nodes;
31 let posts;
33 - if (c_0) {
32 + if ($[0] !== user.timeline.posts.edges.nodes) {
33 posts = user.timeline.posts.edges.nodes.map((node) => <Post post={node} />);
34 let t0;
35 if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
@@ -47,9 +46,8 @@ function Component(props) {
46 }
47 const count = posts.length;
48 foo(count);
50 - const c_3 = $[3] !== posts;
49 let t1;
52 - if (c_3) {
50 + if ($[3] !== posts) {
51 t1 = <>{posts}</>;
52 $[3] = posts;
53 $[4] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassigned-phi-in-returned-function-expression.expect.md
+1 -2
@@ -22,9 +22,8 @@ function Component(props) {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function Component(props) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== props.str;
25 let t0;
27 - if (c_0) {
26 + if ($[0] !== props.str) {
27 t0 = () => {
28 let str = undefined;
29 if (arguments.length) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md
+2 -7
@@ -24,12 +24,9 @@ function Component(props) {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function Component(props) {
26 const $ = useMemoCache(9);
27 - const c_0 = $[0] !== props.p0;
28 - const c_1 = $[1] !== props.p1;
29 - const c_2 = $[2] !== props.p2;
27 let x;
28 let y;
32 - if (c_0 || c_1 || c_2) {
29 + if ($[0] !== props.p0 || $[1] !== props.p1 || $[2] !== props.p2) {
30 x = [];
31 x.push(props.p0);
32 y = x;
@@ -54,10 +51,8 @@ function Component(props) {
51 x = $[3];
52 y = $[4];
53 }
57 - const c_6 = $[6] !== x;
58 - const c_7 = $[7] !== y;
54 let t1;
60 - if (c_6 || c_7) {
55 + if ($[6] !== x || $[7] !== y) {
56 t1 = <Component x={x} y={y} />;
57 $[6] = x;
58 $[7] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md
+5 -11
@@ -42,9 +42,8 @@ export const FIXTURE_ENTRYPOINT = {
42 import { unstable_useMemoCache as useMemoCache } from "react";
43 function foo(a, b, c) {
44 const $ = useMemoCache(11);
45 - const c_0 = $[0] !== a;
45 let x;
47 - if (c_0) {
46 + if ($[0] !== a) {
47 x = [];
48 if (a) {
49 x.push(a);
@@ -54,9 +53,8 @@ function foo(a, b, c) {
53 } else {
54 x = $[1];
55 }
57 - const c_2 = $[2] !== x;
56 let t0;
59 - if (c_2) {
57 + if ($[2] !== x) {
58 t0 = <div>{x}</div>;
59 $[2] = x;
60 $[3] = t0;
@@ -66,8 +64,7 @@ function foo(a, b, c) {
64 const y = t0;
65 bb3: switch (b) {
66 case 0: {
69 - const c_4 = $[4] !== b;
70 - if (c_4) {
67 + if ($[4] !== b) {
68 x = [];
69 x.push(b);
70 $[4] = b;
@@ -78,8 +75,7 @@ function foo(a, b, c) {
75 break bb3;
76 }
77 default: {
81 - const c_6 = $[6] !== c;
82 - if (c_6) {
78 + if ($[6] !== c) {
79 x = [];
80 x.push(c);
81 $[6] = c;
@@ -89,10 +85,8 @@ function foo(a, b, c) {
85 }
86 }
87 }
92 - const c_8 = $[8] !== y;
93 - const c_9 = $[9] !== x;
88 let t1;
95 - if (c_8 || c_9) {
89 + if ($[8] !== y || $[9] !== x) {
90 t1 = (
91 <div>
92 {y}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment.expect.md
+2 -6
@@ -23,11 +23,9 @@ function Component(props) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function Component(props) {
25 const $ = useMemoCache(8);
26 - const c_0 = $[0] !== props.p0;
27 - const c_1 = $[1] !== props.p1;
26 let x;
27 let y;
30 - if (c_0 || c_1) {
28 + if ($[0] !== props.p0 || $[1] !== props.p1) {
29 x = [];
30 x.push(props.p0);
31 y = x;
@@ -49,10 +47,8 @@ function Component(props) {
47 x = $[2];
48 y = $[3];
49 }
52 - const c_5 = $[5] !== x;
53 - const c_6 = $[6] !== y;
50 let t1;
55 - if (c_5 || c_6) {
51 + if ($[5] !== x || $[6] !== y) {
52 t1 = <Component x={x} y={y} />;
53 $[5] = x;
54 $[6] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-condexpr.expect.md
+1 -3
@@ -22,10 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
22
23 function TestCondDepInConditionalExpr(props, other) {
24 const $ = useMemoCache(3);
25 - const c_0 = $[0] !== other;
26 - const c_1 = $[1] !== props.a.b;
25 let t0;
28 - if (c_0 || c_1) {
26 + if ($[0] !== other || $[1] !== props.a.b) {
27 t0 = foo(other) ? bar(props.a.b) : baz(props.a.b);
28 $[0] = other;
29 $[1] = props.a.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-ifelse.expect.md
+1 -3
@@ -27,10 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
27
28 function TestCondDepInDirectIfElse(props, other) {
29 const $ = useMemoCache(3);
30 - const c_0 = $[0] !== other;
31 - const c_1 = $[1] !== props.a.b;
30 let x;
33 - if (c_0 || c_1) {
31 + if ($[0] !== other || $[1] !== props.a.b) {
32 x = {};
33 if (foo(other)) {
34 x.b = props.a.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.expect.md
+1 -3
@@ -27,10 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
27
28 function TestCondDepInNestedIfElse(props, other) {
29 const $ = useMemoCache(3);
30 - const c_0 = $[0] !== other;
31 - const c_1 = $[1] !== props;
30 let x;
33 - if (c_0 || c_1) {
31 + if ($[0] !== other || $[1] !== props) {
32 x = {};
33 if (foo(other)) {
34 if (bar()) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse.expect.md
+1 -3
@@ -33,10 +33,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
33
34 function TestCondDepInNestedIfElse(props, other) {
35 const $ = useMemoCache(3);
36 - const c_0 = $[0] !== other;
37 - const c_1 = $[1] !== props.a.b;
36 let x;
39 - if (c_0 || c_1) {
37 + if ($[0] !== other || $[1] !== props.a.b) {
38 x = {};
39 if (foo(other)) {
40 if (bar()) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-testifelse.expect.md
+1 -3
@@ -40,10 +40,8 @@ import { setProperty } from "shared-runtime";
40 function useFoo(t27) {
41 const $ = useMemoCache(3);
42 const { o, branchCheck } = t27;
43 - const c_0 = $[0] !== branchCheck;
44 - const c_1 = $[1] !== o.value;
43 let x;
46 - if (c_0 || c_1) {
44 + if ($[0] !== branchCheck || $[1] !== o.value) {
45 x = {};
46 if (branchCheck) {
47 setProperty(x, o.value);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-case.expect.md
+1 -3
@@ -31,10 +31,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
31
32 function TestCondDepInSwitchMissingCase(props, other) {
33 const $ = useMemoCache(3);
34 - const c_0 = $[0] !== other;
35 - const c_1 = $[1] !== props;
34 let x;
37 - if (c_0 || c_1) {
35 + if ($[0] !== other || $[1] !== props) {
36 x = {};
37 bb1: switch (foo(other)) {
38 case 1: {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-default.expect.md
+1 -3
@@ -28,10 +28,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
28
29 function TestCondDepInSwitchMissingDefault(props, other) {
30 const $ = useMemoCache(3);
31 - const c_0 = $[0] !== other;
32 - const c_1 = $[1] !== props;
31 let x;
34 - if (c_0 || c_1) {
32 + if ($[0] !== other || $[1] !== props) {
33 x = {};
34 bb1: switch (foo(other)) {
35 case 1: {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch.expect.md
+1 -3
@@ -32,10 +32,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b shou
32
33 function TestCondDepInSwitch(props, other) {
34 const $ = useMemoCache(3);
35 - const c_0 = $[0] !== other;
36 - const c_1 = $[1] !== props.a.b;
35 let x;
38 - if (c_0 || c_1) {
36 + if ($[0] !== other || $[1] !== props.a.b) {
37 x = {};
38 bb1: switch (foo(other)) {
39 case 1: {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-no-uncond.expect.md
+1 -3
@@ -22,10 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // When an object
22 // track the base object as a dependency.
23 function TestOnlyConditionalDependencies(props, other) {
24 const $ = useMemoCache(3);
25 - const c_0 = $[0] !== other;
26 - const c_1 = $[1] !== props;
25 let x;
28 - if (c_0 || c_1) {
26 + if ($[0] !== other || $[1] !== props) {
27 x = {};
28 if (foo(other)) {
29 x.b = props.a.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-promote-uncond.expect.md
+1 -3
@@ -24,10 +24,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // When a conditi
24 // and promote it to an unconditional dependency.
25 function TestPromoteUnconditionalAccessToDependency(props, other) {
26 const $ = useMemoCache(3);
27 - const c_0 = $[0] !== props.a;
28 - const c_1 = $[1] !== other;
27 let x;
30 - if (c_0 || c_1) {
28 + if ($[0] !== props.a || $[1] !== other) {
29 x = {};
30 x.a = props.a.a.a;
31 if (foo(other)) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order1.expect.md
+1 -3
@@ -28,10 +28,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // When a conditi
28 // ordering of accesses should not matter
29 function TestConditionalSubpath1(props, other) {
30 const $ = useMemoCache(3);
31 - const c_0 = $[0] !== props.a;
32 - const c_1 = $[1] !== other;
31 let x;
34 - if (c_0 || c_1) {
32 + if ($[0] !== props.a || $[1] !== other) {
33 x = {};
34 x.b = props.a.b;
35 if (foo(other)) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order2.expect.md
+1 -3
@@ -28,10 +28,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // When a conditi
28 // ordering of accesses should not matter
29 function TestConditionalSubpath2(props, other) {
30 const $ = useMemoCache(3);
31 - const c_0 = $[0] !== other;
32 - const c_1 = $[1] !== props.a;
31 let x;
34 - if (c_0 || c_1) {
32 + if ($[0] !== other || $[1] !== props.a) {
33 x = {};
34 if (foo(other)) {
35 x.a = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order1.expect.md
+1 -3
@@ -26,10 +26,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // When an uncond
26 // ordering of accesses should not matter
27 function TestConditionalSuperpath1(props, other) {
28 const $ = useMemoCache(3);
29 - const c_0 = $[0] !== props.a;
30 - const c_1 = $[1] !== other;
29 let x;
32 - if (c_0 || c_1) {
30 + if ($[0] !== props.a || $[1] !== other) {
31 x = {};
32 x.a = props.a;
33 if (foo(other)) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order2.expect.md
+1 -3
@@ -26,10 +26,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // When an uncond
26 // ordering of accesses should not matter
27 function TestConditionalSuperpath2(props, other) {
28 const $ = useMemoCache(3);
29 - const c_0 = $[0] !== other;
30 - const c_1 = $[1] !== props.a;
29 let x;
32 - if (c_0 || c_1) {
30 + if ($[0] !== other || $[1] !== props.a) {
31 x = {};
32 if (foo(other)) {
33 x.b = props.a.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-memberexpr-join.expect.md
+1 -2
@@ -44,9 +44,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // To preserve th
44
45 function Component(props) {
46 const $ = useMemoCache(2);
47 - const c_0 = $[0] !== props.a;
47 let x;
49 - if (c_0) {
48 + if ($[0] !== props.a) {
49 x = [];
50 x.push(props.a?.b);
51 x.push(props.a.b.c);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-dependencies-optional-member-expression.expect.md
+1 -2
@@ -17,9 +17,8 @@ function Component(props) {
17 import { unstable_useMemoCache as useMemoCache } from "react";
18 function Component(props) {
19 const $ = useMemoCache(2);
20 - const c_0 = $[0] !== props.items;
20 let x;
22 - if (c_0) {
21 + if ($[0] !== props.items) {
22 x = [];
23 x.push(props.items?.length);
24 x.push(props.items?.edges?.map?.(render)?.filter?.(Boolean) ?? []);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-cond-scope.expect.md
+2 -4
@@ -54,14 +54,12 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Some reactive
54
55 function TestReactiveDepsInCondScope(props) {
56 const $ = useMemoCache(4);
57 - const c_0 = $[0] !== props;
57 let x;
59 - if (c_0) {
58 + if ($[0] !== props) {
59 x = {};
60 if (foo) {
62 - const c_2 = $[2] !== props.a.b;
61 let t0;
64 - if (c_2) {
62 + if ($[2] !== props.a.b) {
63 t0 = bar(props.a.b);
64 $[2] = props.a.b;
65 $[3] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-join-uncond-scopes-cond-deps.expect.md
+3 -7
@@ -53,13 +53,11 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // This tests an
53
54 function TestJoinCondDepsInUncondScopes(props) {
55 const $ = useMemoCache(8);
56 - const c_0 = $[0] !== props.a.b;
56 let x;
57 let y;
59 - if (c_0) {
58 + if ($[0] !== props.a.b) {
59 y = {};
61 - const c_3 = $[3] !== props;
62 - if (c_3) {
60 + if ($[3] !== props) {
61 x = {};
62 if (foo) {
63 mutate1(x, props.a.b);
@@ -78,10 +76,8 @@ function TestJoinCondDepsInUncondScopes(props) {
76 x = $[1];
77 y = $[2];
78 }
81 - const c_5 = $[5] !== x;
82 - const c_6 = $[6] !== y;
79 let t0;
84 - if (c_5 || c_6) {
80 + if ($[5] !== x || $[6] !== y) {
81 t0 = [x, y];
82 $[5] = x;
83 $[6] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-descendant.expect.md
+1 -4
@@ -27,11 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we c
27 // (not needed for correctness but for dependency granularity)
28 function TestNonOverlappingDescendantTracked(props) {
29 const $ = useMemoCache(4);
30 - const c_0 = $[0] !== props.a.x.y;
31 - const c_1 = $[1] !== props.a.c.x.y.z;
32 - const c_2 = $[2] !== props.b;
30 let x;
34 - if (c_0 || c_1 || c_2) {
31 + if ($[0] !== props.a.x.y || $[1] !== props.a.c.x.y.z || $[2] !== props.b) {
32 x = {};
33 x.a = props.a.x.y;
34 x.b = props.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-direct.expect.md
+1 -3
@@ -26,10 +26,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we c
26 // (not needed for correctness but for dependency granularity)
27 function TestNonOverlappingTracked(props) {
28 const $ = useMemoCache(3);
29 - const c_0 = $[0] !== props.a.b;
30 - const c_1 = $[1] !== props.a.c;
29 let x;
32 - if (c_0 || c_1) {
30 + if ($[0] !== props.a.b || $[1] !== props.a.c) {
31 x = {};
32 x.b = props.a.b;
33 x.c = props.a.c;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-descendant.expect.md
+1 -2
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we c
27 // a dependency
28 function TestOverlappingDescendantTracked(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.a;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.a) {
32 x = {};
33 x.b = props.a.b.c;
34 x.c = props.a.b.c.x.y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-direct.expect.md
+1 -2
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we c
27 // a dependency
28 function TestOverlappingTracked(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.a;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.a) {
32 x = {};
33 x.b = props.a.b;
34 x.c = props.a.c;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order1.expect.md
+1 -2
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Determine that
27 // Ordering of access should not matter
28 function TestDepsSubpathOrder1(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.a;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.a) {
32 x = {};
33 x.b = props.a.b;
34 x.a = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order2.expect.md
+1 -2
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Determine that
27 // Ordering of access should not matter
28 function TestDepsSubpathOrder2(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.a;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.a) {
32 x = {};
33 x.a = props.a;
34 x.b = props.a.b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order3.expect.md
+1 -2
@@ -27,9 +27,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Determine that
27 // Ordering of access should not matter
28 function TestDepsSubpathOrder3(props) {
29 const $ = useMemoCache(2);
30 - const c_0 = $[0] !== props.a;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.a) {
32 x = {};
33 x.c = props.a.b.c;
34 x.a = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-aliased-no-added-to-dep.expect.md
+1 -2
@@ -33,9 +33,8 @@ function VideoTab() {
33 t0 = $[0];
34 }
35 const x = t0;
36 - const c_1 = $[1] !== x;
36 let t1;
38 - if (c_1) {
37 + if ($[1] !== x) {
38 t1 = <VideoList videos={x} />;
39 $[1] = x;
40 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-aliased-not-added-to-dep-2.expect.md
+2 -4
@@ -21,9 +21,8 @@ function Foo(t20) {
21 const { a } = t20;
22 const ref = useRef();
23 const val = ref.current;
24 - const c_0 = $[0] !== a;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== a) {
26 t0 = { a, val };
27 $[0] = a;
28 $[1] = t0;
@@ -31,9 +30,8 @@ function Foo(t20) {
30 t0 = $[1];
31 }
32 const x = t0;
34 - const c_2 = $[2] !== x;
33 let t1;
36 - if (c_2) {
34 + if ($[2] !== x) {
35 t1 = <VideoList videos={x} />;
36 $[2] = x;
37 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-field-not-added-to-dep.expect.md
+1 -2
@@ -31,9 +31,8 @@ function VideoTab() {
31 t0 = $[0];
32 }
33 const x = t0;
34 - const c_1 = $[1] !== x;
34 let t1;
36 - if (c_1) {
35 + if ($[1] !== x) {
36 t1 = <VideoList videos={x} />;
37 $[1] = x;
38 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep-2.expect.md
+2 -4
@@ -19,9 +19,8 @@ function Foo(t17) {
19 const $ = useMemoCache(4);
20 const { a } = t17;
21 const ref = useRef();
22 - const c_0 = $[0] !== a;
22 let t0;
24 - if (c_0) {
23 + if ($[0] !== a) {
24 t0 = { a, val: ref.current };
25 $[0] = a;
26 $[1] = t0;
@@ -29,9 +28,8 @@ function Foo(t17) {
28 t0 = $[1];
29 }
30 const x = t0;
32 - const c_2 = $[2] !== x;
31 let t1;
34 - if (c_2) {
32 + if ($[2] !== x) {
33 t1 = <VideoList videos={x} />;
34 $[2] = x;
35 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-not-added-to-dep.expect.md
+1 -2
@@ -30,9 +30,8 @@ function VideoTab() {
30 t0 = $[0];
31 }
32 const x = t0;
33 - const c_1 = $[1] !== x;
33 let t1;
35 - if (c_1) {
34 + if ($[1] !== x) {
35 t1 = <VideoList videos={x} />;
36 $[1] = x;
37 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-optional-field-no-added-to-dep.expect.md
+1 -2
@@ -30,9 +30,8 @@ function VideoTab() {
30 t0 = $[0];
31 }
32 const x = t0;
33 - const c_1 = $[1] !== x;
33 let t1;
35 - if (c_1) {
34 + if ($[1] !== x) {
35 t1 = <VideoList videos={x} />;
36 $[1] = x;
37 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-current-write-not-added-to-dep.expect.md
+1 -2
@@ -30,9 +30,8 @@ function VideoTab() {
30 t0 = $[0];
31 }
32 const x = t0;
33 - const c_1 = $[1] !== x;
33 let t1;
35 - if (c_1) {
34 + if ($[1] !== x) {
35 t1 = <VideoList videos={x} />;
36 $[1] = x;
37 $[2] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ref-in-effect.expect.md
+1 -2
@@ -44,9 +44,8 @@ function Component(props) {
44 t1 = $[1];
45 }
46 useEffect(t1);
47 - const c_2 = $[2] !== onChange;
47 let t2;
49 - if (c_2) {
48 + if ($[2] !== onChange) {
49 t2 = <Foo onChange={onChange} />;
50 $[2] = onChange;
51 $[3] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-duplicate-import-specifier.expect.md
+1 -2
@@ -26,9 +26,8 @@ import { useState, unstable_useMemoCache as useMemoCache } from "react";
26 function Component(_props) {
27 const $ = useMemoCache(2);
28 const [x] = useState(0);
29 - const c_0 = $[0] !== x;
29 let t0;
31 - if (c_0) {
30 + if ($[0] !== x) {
31 t0 = { x };
32 $[0] = x;
33 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-duplicate-instruction-from-merge-consecutive-scopes.expect.md
+1 -2
@@ -38,9 +38,8 @@ function Component(id) {
38 t0 = $[0];
39 }
40 const t1 = id ? true : false;
41 - const c_1 = $[1] !== t1;
41 let t2;
43 - if (c_1) {
42 + if ($[1] !== t1) {
43 t2 = (
44 <>
45 {t0}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-reassign-to-variable-without-mutable-range.expect.md
+3 -8
@@ -38,15 +38,12 @@ function Component(a, b) {
38 t1 = $[1];
39 }
40 let y = t1;
41 - const c_2 = $[2] !== a;
42 - const c_3 = $[3] !== b;
43 - if (c_2 || c_3) {
41 + if ($[2] !== a || $[3] !== b) {
42 const z = foo(a);
43 if (FLAG) {
44 x = bar(z);
47 - const c_6 = $[6] !== b;
45 let t2;
49 - if (c_6) {
46 + if ($[6] !== b) {
47 t2 = baz(b);
48 $[6] = b;
49 $[7] = t2;
@@ -63,10 +60,8 @@ function Component(a, b) {
60 x = $[4];
61 y = $[5];
62 }
66 - const c_8 = $[8] !== x;
67 - const c_9 = $[9] !== y;
63 let t3;
69 - if (c_8 || c_9) {
64 + if ($[8] !== x || $[9] !== y) {
65 t3 = [x, y];
66 $[8] = x;
67 $[9] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-scope-missing-mutable-range.expect.md
+1 -2
@@ -22,9 +22,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
22 function HomeDiscoStoreItemTileRating(props) {
23 const $ = useMemoCache(3);
24 const item = useFragment();
25 - const c_0 = $[0] !== item;
25 let count;
27 - if (c_0) {
26 + if ($[0] !== item) {
27 count = 0;
28 const aggregates = item?.aggregates || [];
29 aggregates.forEach((aggregate) => {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro.expect.md
+2 -5
@@ -26,10 +26,9 @@ import { unstable_useMemoCache as useMemoCache } from "react";
26 function Component(props) {
27 const $ = useMemoCache(6);
28 const item = props.item;
29 - const c_0 = $[0] !== item;
29 let baseVideos;
30 let thumbnails;
32 - if (c_0) {
31 + if ($[0] !== item) {
32 thumbnails = [];
33 baseVideos = getBaseVideos(item);
34
@@ -46,10 +45,8 @@ function Component(props) {
45 baseVideos = $[1];
46 thumbnails = $[2];
47 }
49 - const c_3 = $[3] !== baseVideos;
50 - const c_4 = $[4] !== thumbnails;
48 let t0;
52 - if (c_3 || c_4) {
49 + if ($[3] !== baseVideos || $[4] !== thumbnails) {
50 t0 = <FlatList baseVideos={baseVideos} items={thumbnails} />;
51 $[3] = baseVideos;
52 $[4] = thumbnails;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rest-param-with-array-pattern.expect.md
+1 -3
@@ -20,10 +20,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(foo, ...t9) {
21 const $ = useMemoCache(3);
22 const [bar] = t9;
23 - const c_0 = $[0] !== foo;
24 - const c_1 = $[1] !== bar;
23 let t0;
26 - if (c_0 || c_1) {
24 + if ($[0] !== foo || $[1] !== bar) {
25 t0 = [foo, bar];
26 $[0] = foo;
27 $[1] = bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rest-param-with-identifier.expect.md
+1 -3
@@ -20,10 +20,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(foo, ...t9) {
21 const $ = useMemoCache(3);
22 const bar = t9;
23 - const c_0 = $[0] !== foo;
24 - const c_1 = $[1] !== bar;
23 let t0;
26 - if (c_0 || c_1) {
24 + if ($[0] !== foo || $[1] !== bar) {
25 t0 = [foo, bar];
26 $[0] = foo;
27 $[1] = bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rest-param-with-object-spread-pattern.expect.md
+1 -3
@@ -20,10 +20,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
20 function Component(foo, ...t9) {
21 const $ = useMemoCache(3);
22 const { bar } = t9;
23 - const c_0 = $[0] !== foo;
24 - const c_1 = $[1] !== bar;
23 let t0;
26 - if (c_0 || c_1) {
24 + if ($[0] !== foo || $[1] !== bar) {
25 t0 = [foo, bar];
26 $[0] = foo;
27 $[1] = bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-9a47e97b5d13.expect.md
+1 -3
@@ -19,10 +19,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Valid because
19 const FancyButton = React.forwardRef(function (props, ref) {
20 const $ = useMemoCache(3);
21 useHook();
22 - const c_0 = $[0] !== props;
23 - const c_1 = $[1] !== ref;
22 let t0;
25 - if (c_0 || c_1) {
23 + if ($[0] !== props || $[1] !== ref) {
24 t0 = <button {...props} ref={ref} />;
25 $[0] = props;
26 $[1] = ref;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-e66a744cffbe.expect.md
+1 -3
@@ -19,10 +19,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Valid because
19 const FancyButton = forwardRef(function (props, ref) {
20 const $ = useMemoCache(3);
21 useHook();
22 - const c_0 = $[0] !== props;
23 - const c_1 = $[1] !== ref;
22 let t0;
25 - if (c_0 || c_1) {
23 + if ($[0] !== props || $[1] !== ref) {
24 t0 = <button {...props} ref={ref} />;
25 $[0] = props;
26 $[1] = ref;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-eacfcaa6ef89.expect.md
+1 -2
@@ -19,9 +19,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // Valid because
19 const MemoizedFunction = memo(function (props) {
20 const $ = useMemoCache(2);
21 useHook();
22 - const c_0 = $[0] !== props;
22 let t0;
24 - if (c_0) {
23 + if ($[0] !== props) {
24 t0 = <button {...props} />;
25 $[0] = props;
26 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md
+5 -15
@@ -53,9 +53,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // note: comments
53 // emitted
54 function foo(props) {
55 const $ = useMemoCache(16);
56 - const c_0 = $[0] !== props.a;
56 let x;
58 - if (c_0) {
57 + if ($[0] !== props.a) {
58 x = [];
59 x.push(props.a);
60 $[0] = props.a;
@@ -63,10 +62,8 @@ function foo(props) {
62 } else {
63 x = $[1];
64 }
66 - const c_2 = $[2] !== props.showHeader;
67 - const c_3 = $[3] !== x;
65 let t0;
69 - if (c_2 || c_3) {
66 + if ($[2] !== props.showHeader || $[3] !== x) {
67 t0 = props.showHeader ? <div>{x}</div> : null;
68 $[2] = props.showHeader;
69 $[3] = x;
@@ -75,11 +72,8 @@ function foo(props) {
72 t0 = $[4];
73 }
74 const header = t0;
78 - const c_5 = $[5] !== x;
79 - const c_6 = $[6] !== props.b;
80 - const c_7 = $[7] !== props.c;
75 let y;
82 - if (c_5 || c_6 || c_7) {
76 + if ($[5] !== x || $[6] !== props.b || $[7] !== props.c) {
77 y = [x];
78 x = [];
79 y.push(props.b);
@@ -93,10 +87,8 @@ function foo(props) {
87 y = $[8];
88 x = $[9];
89 }
96 - const c_10 = $[10] !== x;
97 - const c_11 = $[11] !== y;
90 let t1;
99 - if (c_10 || c_11) {
91 + if ($[10] !== x || $[11] !== y) {
92 t1 = (
93 <div>
94 {x}
@@ -110,10 +102,8 @@ function foo(props) {
102 t1 = $[12];
103 }
104 const content = t1;
113 - const c_13 = $[13] !== header;
114 - const c_14 = $[14] !== content;
105 let t2;
116 - if (c_13 || c_14) {
106 + if ($[13] !== header || $[14] !== content) {
107 t2 = (
108 <>
109 {header}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md
+5 -14
@@ -53,9 +53,8 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // note: comments
53 // emitted
54 function foo(props) {
55 const $ = useMemoCache(15);
56 - const c_0 = $[0] !== props.a;
56 let x;
58 - if (c_0) {
57 + if ($[0] !== props.a) {
58 x = [];
59 x.push(props.a);
60 $[0] = props.a;
@@ -63,9 +62,8 @@ function foo(props) {
62 } else {
63 x = $[1];
64 }
66 - const c_2 = $[2] !== x;
65 let t0;
68 - if (c_2) {
66 + if ($[2] !== x) {
67 t0 = <div>{x}</div>;
68 $[2] = x;
69 $[3] = t0;
@@ -73,11 +71,8 @@ function foo(props) {
71 t0 = $[3];
72 }
73 const header = t0;
76 - const c_4 = $[4] !== x;
77 - const c_5 = $[5] !== props.b;
78 - const c_6 = $[6] !== props.c;
74 let y;
80 - if (c_4 || c_5 || c_6) {
75 + if ($[4] !== x || $[5] !== props.b || $[6] !== props.c) {
76 y = [x];
77 x = [];
78 y.push(props.b);
@@ -91,10 +86,8 @@ function foo(props) {
86 y = $[7];
87 x = $[8];
88 }
94 - const c_9 = $[9] !== x;
95 - const c_10 = $[10] !== y;
89 let t1;
97 - if (c_9 || c_10) {
90 + if ($[9] !== x || $[10] !== y) {
91 t1 = (
92 <div>
93 {x}
@@ -108,10 +101,8 @@ function foo(props) {
101 t1 = $[11];
102 }
103 const content = t1;
111 - const c_12 = $[12] !== header;
112 - const c_13 = $[13] !== content;
104 let t2;
114 - if (c_12 || c_13) {
105 + if ($[12] !== header || $[13] !== content) {
106 t2 = (
107 <>
108 {header}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple-scope.expect.md
+1 -2
@@ -21,9 +21,8 @@ export const FIXTURE_ENTRYPOINT = {
21 import { unstable_useMemoCache as useMemoCache } from "react";
22 function foo(a) {
23 const $ = useMemoCache(2);
24 - const c_0 = $[0] !== a.b;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== a.b) {
26 t0 = [a.b];
27 $[0] = a.b;
28 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple.expect.md
+2 -4
@@ -18,9 +18,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
18 export default function foo(x, y) {
19 const $ = useMemoCache(4);
20 if (x) {
21 - const c_0 = $[0] !== y;
21 let t0;
23 - if (c_0) {
22 + if ($[0] !== y) {
23 t0 = foo(false, y);
24 $[0] = y;
25 $[1] = t0;
@@ -31,9 +30,8 @@ export default function foo(x, y) {
30 }
31
32 const t1 = y * 10;
34 - const c_2 = $[2] !== t1;
33 let t2;
36 - if (c_2) {
34 + if ($[2] !== t1) {
35 t2 = [t1];
36 $[2] = t1;
37 $[3] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-cascading-eliminated-phis.expect.md
+1 -2
@@ -33,9 +33,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
33 function Component(props) {
34 const $ = useMemoCache(3);
35 let x = 0;
36 - const c_0 = $[0] !== props;
36 let values;
38 - if (c_0) {
37 + if ($[0] !== props) {
38 values = [];
39 const y = props.a || props.b;
40 values.push(y);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md
+2 -5
@@ -25,10 +25,9 @@ function Component(props) {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function Component(props) {
27 const $ = useMemoCache(6);
28 - const c_0 = $[0] !== props;
28 let x;
29 let y;
31 - if (c_0) {
30 + if ($[0] !== props) {
31 x = [];
32 if (props.p0) {
33 x.push(props.p1);
@@ -41,10 +40,8 @@ function Component(props) {
40 x = $[1];
41 y = $[2];
42 }
44 - const c_3 = $[3] !== x;
45 - const c_4 = $[4] !== y;
43 let t0;
47 - if (c_3 || c_4) {
44 + if ($[3] !== x || $[4] !== y) {
45 t0 = (
46 <Component>
47 {x}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-alias-mutate-if.expect.md
+1 -2
@@ -24,9 +24,8 @@ function foo(a) {
24 import { unstable_useMemoCache as useMemoCache } from "react";
25 function foo(a) {
26 const $ = useMemoCache(2);
27 - const c_0 = $[0] !== a;
27 let x;
29 - if (c_0) {
28 + if ($[0] !== a) {
29 const b = {};
30 x = b;
31 if (a) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md
+1 -2
@@ -28,9 +28,8 @@ export const FIXTURE_ENTRYPOINT = {
28 import { unstable_useMemoCache as useMemoCache } from "react";
29 function foo(a) {
30 const $ = useMemoCache(4);
31 - const c_0 = $[0] !== a;
31 let x;
33 - if (c_0) {
32 + if ($[0] !== a) {
33 x = {};
34 if (a) {
35 let t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-if.expect.md
+1 -2
@@ -23,9 +23,8 @@ function foo(a) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function foo(a) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== a;
26 let x;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 x = {};
29 if (a) {
30 const y = {};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-inside-if.expect.md
+1 -2
@@ -23,9 +23,8 @@ function foo(a) {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function foo(a) {
25 const $ = useMemoCache(3);
26 - const c_0 = $[0] !== a;
26 let x;
28 - if (c_0) {
27 + if ($[0] !== a) {
28 x = {};
29 if (a) {
30 const y = {};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md
+1 -2
@@ -18,9 +18,8 @@ function foo(props) {
18 import { unstable_useMemoCache as useMemoCache } from "react";
19 function foo(props) {
20 const $ = useMemoCache(2);
21 - const c_0 = $[0] !== props;
21 let x;
23 - if (c_0) {
22 + if ($[0] !== props) {
23 x = [];
24 x.push(props.bar);
25 props.cond ? (([x] = [[]]), x.push(props.foo)) : null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md
+1 -2
@@ -23,9 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function foo(props) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== props.bar;
26 let x;
28 - if (c_0) {
27 + if ($[0] !== props.bar) {
28 x = [];
29 x.push(props.bar);
30 $[0] = props.bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md
+1 -2
@@ -18,9 +18,8 @@ function foo(props) {
18 import { unstable_useMemoCache as useMemoCache } from "react";
19 function foo(props) {
20 const $ = useMemoCache(2);
21 - const c_0 = $[0] !== props;
21 let x;
23 - if (c_0) {
22 + if ($[0] !== props) {
23 x = [];
24 x.push(props.bar);
25 props.cond ? ((x = []), x.push(props.foo)) : null;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md
+1 -2
@@ -23,9 +23,8 @@ export const FIXTURE_ENTRYPOINT = {
23 import { unstable_useMemoCache as useMemoCache } from "react";
24 function foo(props) {
25 const $ = useMemoCache(2);
26 - const c_0 = $[0] !== props.bar;
26 let x;
28 - if (c_0) {
27 + if ($[0] !== props.bar) {
28 x = [];
29 x.push(props.bar);
30 $[0] = props.bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md
+1 -2
@@ -20,9 +20,8 @@ function foo(props) {
20 import { unstable_useMemoCache as useMemoCache } from "react";
21 function foo(props) {
22 const $ = useMemoCache(2);
23 - const c_0 = $[0] !== props;
23 let x;
25 - if (c_0) {
24 + if ($[0] !== props) {
25 x = [];
26 x.push(props.bar);
27 props.cond ? ((x = []), x.push(props.foo)) : ((x = []), x.push(props.bar));
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md
+1 -2
@@ -25,9 +25,8 @@ export const FIXTURE_ENTRYPOINT = {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function foo(props) {
27 const $ = useMemoCache(2);
28 - const c_0 = $[0] !== props.bar;
28 let x;
30 - if (c_0) {
29 + if ($[0] !== props.bar) {
30 x = [];
31 x.push(props.bar);
32 $[0] = props.bar;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md
+1 -2
@@ -26,9 +26,8 @@ function foo(props) {
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 function foo(props) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== props;
29 let x;
31 - if (c_0) {
30 + if ($[0] !== props) {
31 x = [];
32 x.push(props.bar);
33 if (props.cond) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring-with-mutation.expect.md
+1 -2
@@ -22,9 +22,8 @@ function foo(props) {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function foo(props) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== props;
25 let x;
27 - if (c_0) {
26 + if ($[0] !== props) {
27 ({ x } = { x: [] });
28 x.push(props.bar);
29 if (props.cond) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring.expect.md
+2 -4
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function foo(props) {
29 const $ = useMemoCache(4);
30 - const c_0 = $[0] !== props.bar;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.bar) {
32 ({ x } = { x: [] });
33 x.push(props.bar);
34 $[0] = props.bar;
@@ -38,8 +37,7 @@ function foo(props) {
37 x = $[1];
38 }
39 if (props.cond) {
41 - const c_2 = $[2] !== props.foo;
42 - if (c_2) {
40 + if ($[2] !== props.foo) {
41 ({ x } = { x: [] });
42 x.push(props.foo);
43 $[2] = props.foo;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming-with-mutation.expect.md
+1 -2
@@ -22,9 +22,8 @@ function foo(props) {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function foo(props) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== props;
25 let x;
27 - if (c_0) {
26 + if ($[0] !== props) {
27 x = [];
28 x.push(props.bar);
29 if (props.cond) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-renaming.expect.md
+2 -4
@@ -27,9 +27,8 @@ export const FIXTURE_ENTRYPOINT = {
27 import { unstable_useMemoCache as useMemoCache } from "react";
28 function foo(props) {
29 const $ = useMemoCache(4);
30 - const c_0 = $[0] !== props.bar;
30 let x;
32 - if (c_0) {
31 + if ($[0] !== props.bar) {
32 x = [];
33 x.push(props.bar);
34 $[0] = props.bar;
@@ -38,8 +37,7 @@ function foo(props) {
37 x = $[1];
38 }
39 if (props.cond) {
41 - const c_2 = $[2] !== props.foo;
42 - if (c_2) {
40 + if ($[2] !== props.foo) {
41 x = [];
42 x.push(props.foo);
43 $[2] = props.foo;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md
+3 -7
@@ -34,10 +34,9 @@ function Component(props) {
34 import { unstable_useMemoCache as useMemoCache } from "react";
35 function Component(props) {
36 const $ = useMemoCache(9);
37 - const c_0 = $[0] !== props;
37 let x;
38 let y;
40 - if (c_0) {
39 + if ($[0] !== props) {
40 x = [];
41 bb1: switch (props.p0) {
42 case 1: {
@@ -68,9 +67,8 @@ function Component(props) {
67 x = $[1];
68 y = $[2];
69 }
71 - const c_4 = $[4] !== x;
70 let t1;
73 - if (c_4) {
71 + if ($[4] !== x) {
72 t1 = <Component data={x} />;
73 $[4] = x;
74 $[5] = t1;
@@ -79,10 +77,8 @@ function Component(props) {
77 }
78 const child = t1;
79 y.push(props.p4);
82 - const c_6 = $[6] !== y;
83 - const c_7 = $[7] !== child;
80 let t2;
85 - if (c_6 || c_7) {
81 + if ($[6] !== y || $[7] !== child) {
82 t2 = <Component data={y}>{child}</Component>;
83 $[6] = y;
84 $[7] = child;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch.expect.md
+3 -7
@@ -29,10 +29,9 @@ function Component(props) {
29 import { unstable_useMemoCache as useMemoCache } from "react";
30 function Component(props) {
31 const $ = useMemoCache(8);
32 - const c_0 = $[0] !== props;
32 let x;
33 let y;
35 - if (c_0) {
34 + if ($[0] !== props) {
35 x = [];
36 switch (props.p0) {
37 case true: {
@@ -50,9 +49,8 @@ function Component(props) {
49 x = $[1];
50 y = $[2];
51 }
53 - const c_3 = $[3] !== x;
52 let t0;
55 - if (c_3) {
53 + if ($[3] !== x) {
54 t0 = <Component data={x} />;
55 $[3] = x;
56 $[4] = t0;
@@ -61,10 +59,8 @@ function Component(props) {
59 }
60 const child = t0;
61 y.push(props.p4);
64 - const c_5 = $[5] !== y;
65 - const c_6 = $[6] !== child;
62 let t1;
67 - if (c_5 || c_6) {
63 + if ($[5] !== y || $[6] !== child) {
64 t1 = <Component data={y}>{child}</Component>;
65 $[5] = y;
66 $[6] = child;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/temporary-accessed-outside-scope.expect.md
+2 -5
@@ -16,10 +16,9 @@ function Component(props) {
16 import { unstable_useMemoCache as useMemoCache } from "react";
17 function Component(props) {
18 const $ = useMemoCache(6);
19 - const c_0 = $[0] !== props;
19 let t0;
20 let t1;
22 - if (c_0) {
21 + if ($[0] !== props) {
22 const maybeMutable = new MaybeMutable();
23 const x = props;
24 t0 = x;
@@ -31,10 +30,8 @@ function Component(props) {
30 t0 = $[1];
31 t1 = $[2];
32 }
34 - const c_3 = $[3] !== t0;
35 - const c_4 = $[4] !== t1;
33 let t2;
37 - if (c_3 || c_4) {
34 + if ($[3] !== t0 || $[4] !== t1) {
35 t2 = [t0, t1];
36 $[3] = t0;
37 $[4] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/temporary-at-start-of-value-block.expect.md
+1 -2
@@ -16,9 +16,8 @@ function component(props) {
16 import { unstable_useMemoCache as useMemoCache } from "react";
17 function component(props) {
18 const $ = useMemoCache(2);
19 - const c_0 = $[0] !== props;
19 let t0;
21 - if (c_0) {
20 + if ($[0] !== props) {
21 t0 = isMenuShown ? <Bar> {props.a ? props.b : props.c}</Bar> : null;
22 $[0] = props;
23 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/temporary-property-load-accessed-outside-scope.expect.md
+2 -5
@@ -16,10 +16,9 @@ function Component(props) {
16 import { unstable_useMemoCache as useMemoCache } from "react";
17 function Component(props) {
18 const $ = useMemoCache(6);
19 - const c_0 = $[0] !== props.value;
19 let t0;
20 let t1;
22 - if (c_0) {
21 + if ($[0] !== props.value) {
22 const maybeMutable = new MaybeMutable();
23 const x = props.value;
24 t0 = x;
@@ -31,10 +30,8 @@ function Component(props) {
30 t0 = $[1];
31 t1 = $[2];
32 }
34 - const c_3 = $[3] !== t0;
35 - const c_4 = $[4] !== t1;
33 let t2;
37 - if (c_3 || c_4) {
34 + if ($[3] !== t0 || $[4] !== t1) {
35 t2 = [t0, t1];
36 $[3] = t0;
37 $[4] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/todo-function-expression-captures-value-later-frozen.expect.md
+2 -4
@@ -25,9 +25,8 @@ function Component(props) {
25 import { unstable_useMemoCache as useMemoCache } from "react";
26 function Component(props) {
27 const $ = useMemoCache(4);
28 - const c_0 = $[0] !== props.cond;
28 let x;
30 - if (c_0) {
29 + if ($[0] !== props.cond) {
30 x = {};
31
32 const onChange = (e) => {
@@ -42,9 +41,8 @@ function Component(props) {
41 } else {
42 x = $[1];
43 }
45 - const c_2 = $[2] !== x;
44 let t0;
47 - if (c_2) {
45 + if ($[2] !== x) {
46 t0 = <Foo value={x} />;
47 $[2] = x;
48 $[3] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-mutate-outer-value.expect.md
+1 -2
@@ -29,9 +29,8 @@ const { shallowCopy, throwErrorWithMessage } = require("shared-runtime");
29
30 function Component(props) {
31 const $ = useMemoCache(3);
32 - const c_0 = $[0] !== props.a;
32 let x;
34 - if (c_0) {
33 + if ($[0] !== props.a) {
34 x = [];
35 try {
36 let t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch-escaping.expect.md
+1 -3
@@ -33,9 +33,7 @@ const { throwInput } = require("shared-runtime");
33 function Component(props) {
34 const $ = useMemoCache(3);
35 let x;
36 - const c_0 = $[0] !== props.y;
37 - const c_1 = $[1] !== props.e;
38 - if (c_0 || c_1) {
36 + if ($[0] !== props.y || $[1] !== props.e) {
37 try {
38 const y = [];
39 y.push(props.y);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-within-mutable-range.expect.md
+1 -2
@@ -30,9 +30,8 @@ const { throwErrorWithMessage, shallowCopy } = require("shared-runtime");
30
31 function Component(props) {
32 const $ = useMemoCache(4);
33 - const c_0 = $[0] !== props.value;
33 let x;
35 - if (c_0) {
34 + if ($[0] !== props.value) {
35 x = [];
36 try {
37 let t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/type-cast-expression.flow.expect.md
+1 -2
@@ -26,9 +26,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
26 type Foo = { bar: string };
27 function Component(props) {
28 const $ = useMemoCache(2);
29 - const c_0 = $[0] !== props.bar;
29 let y;
31 - if (c_0) {
30 + if ($[0] !== props.bar) {
31 const x = { bar: props.bar };
32 y = (x: Foo);
33 y.bar = "hello";
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unary-expr.expect.md
+9 -8
@@ -36,15 +36,16 @@ function component(a) {
36 const m = !t.t;
37 const e = ~t.t;
38 const f = typeof t.t;
39 - const c_0 = $[0] !== z;
40 - const c_1 = $[1] !== p;
41 - const c_2 = $[2] !== q;
42 - const c_3 = $[3] !== n;
43 - const c_4 = $[4] !== m;
44 - const c_5 = $[5] !== e;
45 - const c_6 = $[6] !== f;
39 let t0;
47 - if (c_0 || c_1 || c_2 || c_3 || c_4 || c_5 || c_6) {
40 + if (
41 + $[0] !== z ||
42 + $[1] !== p ||
43 + $[2] !== q ||
44 + $[3] !== n ||
45 + $[4] !== m ||
46 + $[5] !== e ||
47 + $[6] !== f
48 + ) {
49 t0 = { z, p, q, n, m, e, f };
50 $[0] = z;
51 $[1] = p;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md
+1 -2
@@ -22,9 +22,8 @@ export const FIXTURE_ENTRYPOINT = {
22 import { unstable_useMemoCache as useMemoCache } from "react";
23 function Foo(props) {
24 const $ = useMemoCache(2);
25 - const c_0 = $[0] !== props.a;
25 let rest;
27 - if (c_0) {
26 + if ($[0] !== props.a) {
27 const { unused, ...t15 } = props.a;
28 rest = t15;
29 $[0] = props.a;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-in-sequence.expect.md
+1 -5
@@ -34,12 +34,8 @@ function Component(props) {
34 if (props.cond) {
35 d = ((b = a), a++, (c = a), ++a);
36 }
37 - const c_0 = $[0] !== a;
38 - const c_1 = $[1] !== b;
39 - const c_2 = $[2] !== c;
40 - const c_3 = $[3] !== d;
37 let t0;
42 - if (c_0 || c_1 || c_2 || c_3) {
38 + if ($[0] !== a || $[1] !== b || $[2] !== c || $[3] !== d) {
39 t0 = [a, b, c, d];
40 $[0] = a;
41 $[1] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-on-function-parameter.expect.md
+11 -10
@@ -35,17 +35,18 @@ function Component(a, t37, t38) {
35 const g = --b;
36 const h = c++;
37 const i = --c;
38 - const c_0 = $[0] !== a;
39 - const c_1 = $[1] !== b;
40 - const c_2 = $[2] !== c;
41 - const c_3 = $[3] !== d;
42 - const c_4 = $[4] !== e;
43 - const c_5 = $[5] !== f;
44 - const c_6 = $[6] !== g;
45 - const c_7 = $[7] !== h;
46 - const c_8 = $[8] !== i;
38 let t0;
48 - if (c_0 || c_1 || c_2 || c_3 || c_4 || c_5 || c_6 || c_7 || c_8) {
39 + if (
40 + $[0] !== a ||
41 + $[1] !== b ||
42 + $[2] !== c ||
43 + $[3] !== d ||
44 + $[4] !== e ||
45 + $[5] !== f ||
46 + $[6] !== g ||
47 + $[7] !== h ||
48 + $[8] !== i
49 + ) {
50 t0 = [a, b, c, d, e, f, g, h, i];
51 $[0] = a;
52 $[1] = b;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression.expect.md
+1 -4
@@ -26,11 +26,8 @@ function foo(props) {
26 let x = props.x;
27 const y = x++;
28 const z = x--;
29 - const c_0 = $[0] !== x;
30 - const c_1 = $[1] !== y;
31 - const c_2 = $[2] !== z;
29 let t0;
33 - if (c_0 || c_1 || c_2) {
30 + if ($[0] !== x || $[1] !== y || $[2] !== z) {
31 t0 = { x, y, z };
32 $[0] = x;
33 $[1] = y;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/use-callback-simple.expect.md
+2 -4
@@ -18,9 +18,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
18 function component() {
19 const $ = useMemoCache(4);
20 const [count, setCount] = useState(0);
21 - const c_0 = $[0] !== count;
21 let t0;
23 - if (c_0) {
22 + if ($[0] !== count) {
23 t0 = () => setCount(count + 1);
24 $[0] = count;
25 $[1] = t0;
@@ -28,9 +27,8 @@ function component() {
27 t0 = $[1];
28 }
29 const increment = t0;
31 - const c_2 = $[2] !== increment;
30 let t1;
33 - if (c_2) {
31 + if ($[2] !== increment) {
32 t1 = <Foo onClick={increment} />;
33 $[2] = increment;
34 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useContext-maybe-mutate-context-in-callback.expect.md
+2 -5
@@ -39,9 +39,8 @@ const FooContext = React.createContext({ current: null });
39 function Component(props) {
40 const $ = useMemoCache(5);
41 const Foo = useContext(FooContext);
42 - const c_0 = $[0] !== Foo.current;
42 let t0;
44 - if (c_0) {
43 + if ($[0] !== Foo.current) {
44 t0 = () => {
45 mutate(Foo.current);
46 };
@@ -51,10 +50,8 @@ function Component(props) {
50 t0 = $[1];
51 }
52 const onClick = t0;
54 - const c_2 = $[2] !== onClick;
55 - const c_3 = $[3] !== props.children;
53 let t1;
57 - if (c_2 || c_3) {
54 + if ($[2] !== onClick || $[3] !== props.children) {
55 t1 = <div onClick={onClick}>{props.children}</div>;
56 $[2] = onClick;
57 $[3] = props.children;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useContext-read-context-in-callback-if-condition.expect.md
+3 -6
@@ -42,9 +42,8 @@ const FooContext = createContext({ current: true });
42 function Component(props) {
43 const $ = useMemoCache(6);
44 const foo = useContext(FooContext);
45 - const c_0 = $[0] !== foo.current;
45 let t0;
47 - if (c_0) {
46 + if ($[0] !== foo.current) {
47 t0 = () => {
48 if (foo.current) {
49 return {};
@@ -58,9 +57,8 @@ function Component(props) {
57 t0 = $[1];
58 }
59 const getValue = t0;
61 - const c_2 = $[2] !== getValue;
60 let t1;
63 - if (c_2) {
61 + if ($[2] !== getValue) {
62 t1 = getValue();
63 $[2] = getValue;
64 $[3] = t1;
@@ -68,9 +66,8 @@ function Component(props) {
66 t1 = $[3];
67 }
68 const value = t1;
71 - const c_4 = $[4] !== value;
69 let t2;
73 - if (c_4) {
70 + if ($[4] !== value) {
71 t2 = <Child value={value} />;
72 $[4] = value;
73 $[5] = t2;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useContext-read-context-in-callback.expect.md
+2 -5
@@ -36,9 +36,8 @@ const FooContext = createContext({ current: null });
36 function Component(props) {
37 const $ = useMemoCache(5);
38 const foo = useContext(FooContext);
39 - const c_0 = $[0] !== foo.current;
39 let t0;
41 - if (c_0) {
40 + if ($[0] !== foo.current) {
41 t0 = () => {
42 console.log(foo.current);
43 };
@@ -48,10 +47,8 @@ function Component(props) {
47 t0 = $[1];
48 }
49 const onClick = t0;
51 - const c_2 = $[2] !== onClick;
52 - const c_3 = $[3] !== props.children;
50 let t1;
54 - if (c_2 || c_3) {
51 + if ($[2] !== onClick || $[3] !== props.children) {
52 t1 = <div onClick={onClick}>{props.children}</div>;
53 $[2] = onClick;
54 $[3] = props.children;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useEffect-arg-memoized.expect.md
+2 -4
@@ -29,9 +29,8 @@ function Component(props) {
29 const $ = useMemoCache(6);
30 const dispatch = useDispatch();
31 useFreeze(dispatch);
32 - const c_0 = $[0] !== dispatch;
32 let t0;
34 - if (c_0) {
33 + if ($[0] !== dispatch) {
34 t0 = () => {
35 dispatch({ kind: "update" });
36 };
@@ -41,10 +40,9 @@ function Component(props) {
40 t0 = $[1];
41 }
42 const onUpdate = t0;
44 - const c_2 = $[2] !== onUpdate;
43 let t1;
44 let t2;
47 - if (c_2) {
45 + if ($[2] !== onUpdate) {
46 t1 = () => {
47 onUpdate();
48 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useEffect-nested-lambdas.expect.md
+1 -2
@@ -36,9 +36,8 @@ function Component(props) {
36 const item = useMutable(props.itemId);
37 const dispatch = useDispatch();
38 useFreeze(dispatch);
39 - const c_0 = $[0] !== dispatch;
39 let t0;
41 - if (c_0) {
40 + if ($[0] !== dispatch) {
41 t0 = () => {
42 dispatch(createExitAction());
43 };
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md
+2 -4
@@ -23,9 +23,8 @@ function Component(props) {
23 let t44;
24 bb8: {
25 if (props.cond) {
26 - const c_0 = $[0] !== props.a;
26 let t0;
28 - if (c_0) {
27 + if ($[0] !== props.a) {
28 t0 = makeObject(props.a);
29 $[0] = props.a;
30 $[1] = t0;
@@ -35,9 +34,8 @@ function Component(props) {
34 t44 = t0;
35 break bb8;
36 }
38 - const c_2 = $[2] !== props.b;
37 let t1;
40 - if (c_2) {
38 + if ($[2] !== props.b) {
39 t1 = makeObject(props.b);
40 $[2] = props.b;
41 $[3] = t1;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md
+4 -10
@@ -21,9 +21,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
21 function Component(props) {
22 const $ = useMemoCache(10);
23 let t59;
24 - const c_0 = $[0] !== props.a;
24 let t0;
26 - if (c_0) {
25 + if ($[0] !== props.a) {
26 t0 = makeObject(props.a);
27 $[0] = props.a;
28 $[1] = t0;
@@ -31,9 +30,8 @@ function Component(props) {
30 t0 = $[1];
31 }
32 const a = t0;
34 - const c_2 = $[2] !== props.b;
33 let t1;
36 - if (c_2) {
34 + if ($[2] !== props.b) {
35 t1 = makeObject(props.b);
36 $[2] = props.b;
37 $[3] = t1;
@@ -41,10 +39,8 @@ function Component(props) {
39 t1 = $[3];
40 }
41 const b = t1;
44 - const c_4 = $[4] !== a;
45 - const c_5 = $[5] !== b;
42 let t2;
47 - if (c_4 || c_5) {
43 + if ($[4] !== a || $[5] !== b) {
44 t2 = [a, b];
45 $[4] = a;
46 $[5] = b;
@@ -54,10 +50,8 @@ function Component(props) {
50 }
51 t59 = t2;
52 const [a_0, b_0] = t59;
57 - const c_7 = $[7] !== a_0;
58 - const c_8 = $[8] !== b_0;
53 let t3;
60 - if (c_7 || c_8) {
54 + if ($[7] !== a_0 || $[8] !== b_0) {
55 t3 = [a_0, b_0];
56 $[7] = a_0;
57 $[8] = b_0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md
+1 -2
@@ -28,9 +28,8 @@ function component(a, b) {
28 let t31;
29 bb7: {
30 if (a) {
31 - const c_0 = $[0] !== b;
31 let t0;
33 - if (c_0) {
32 + if ($[0] !== b) {
33 t0 = { b };
34 $[0] = b;
35 $[1] = t0;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md
+1 -2
@@ -35,9 +35,8 @@ function Component(props) {
35 const $ = useMemoCache(3);
36 let t68;
37 bb10: {
38 - const c_0 = $[0] !== props;
38 let y;
40 - if (c_0) {
39 + if ($[0] !== props) {
40 y = [];
41 if (props.cond) {
42 y.push(props.a);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md
+2 -4
@@ -16,9 +16,8 @@ import { unstable_useMemoCache as useMemoCache } from "react";
16 function component(a) {
17 const $ = useMemoCache(4);
18 let t24;
19 - const c_0 = $[0] !== a;
19 let t0;
21 - if (c_0) {
20 + if ($[0] !== a) {
21 t0 = [a];
22 $[0] = a;
23 $[1] = t0;
@@ -27,9 +26,8 @@ function component(a) {
26 }
27 t24 = t0;
28 const x = t24;
30 - const c_2 = $[2] !== x;
29 let t1;
32 - if (c_2) {
30 + if ($[2] !== x) {
31 t1 = <Foo x={x} />;
32 $[2] = x;
33 $[3] = t1;