@samitouri / QOS-React / commits / b00300c4cf

Remove disableAllMemoization flag

Joe Savona committed Apr 1, 2024 at 15:18 UTC b00300c4cfa1e05321851b061c3eed9ebc8f3f08
4 files changed -68
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Pipeline.ts
-10
@@ -55,7 +55,6 @@ import {
55 promoteUsedTemporaries,
56 propagateEarlyReturns,
57 propagateScopeDependencies,
58 - pruneAllReactiveScopes,
58 pruneHoistedContexts,
59 pruneNonEscapingScopes,
60 pruneNonReactiveDependencies,
@@ -269,15 +268,6 @@ function* runWithEnvironment(
268 value: reactiveFunction,
269 });
270
272 - if (env.config.disableAllMemoization) {
273 - pruneAllReactiveScopes(reactiveFunction);
274 - yield log({
275 - kind: "reactive",
276 - name: "PruneAllReactiveScopes",
277 - value: reactiveFunction,
278 - });
279 - }
280 -
271 flattenReactiveLoops(reactiveFunction);
272 yield log({
273 kind: "reactive",
compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts
-7
@@ -231,13 +231,6 @@ const EnvironmentConfigSchema = z.object({
231 */
232 enableTransitivelyFreezeFunctionExpressions: z.boolean().default(true),
233
234 - /*
235 - * When enabled, removes *all* memoization from the function: this includes
236 - * removing manually added useMemo/useCallback as well as not adding Forget's
237 - * usual useMemoCache-based memoization.
238 - */
239 - disableAllMemoization: z.boolean().default(false),
240 -
234 /*
235 * Enables codegen mutability debugging. This emits a dev-mode only to log mutations
236 * to values that Forget assumes are immutable (for Forget compiled code).
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.expect.md deleted
-39
@@ -1,39 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// @disableAllMemoization true
6 -function Component(props) {
7 - const [x, setX] = useState(() => initializeState(props));
8 - const onChange = useCallback((e) => {
9 - setX(e.target.value);
10 - });
11 - const object = { x, onChange };
12 - return useMemo(() => {
13 - const { x, onChange } = object;
14 - return <input value={x} onChange={onChange} />;
15 - }, [x]);
16 -}
17 -
18 -```
19 -
20 -## Code
21 -
22 -```javascript
23 -// @disableAllMemoization true
24 -function Component(props) {
25 - const [x, setX] = useState(() => initializeState(props));
26 - const onChange = (e) => {
27 - setX(e.target.value);
28 - };
29 -
30 - const object = { x, onChange };
31 - let t0;
32 -
33 - const { x: x_0, onChange: onChange_0 } = object;
34 - t0 = <input value={x_0} onChange={onChange_0} />;
35 - return t0;
36 -}
37 -
38 -```
39 -
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.js deleted
-12
@@ -1,12 +0,0 @@
1 -// @disableAllMemoization true
2 -function Component(props) {
3 - const [x, setX] = useState(() => initializeState(props));
4 - const onChange = useCallback((e) => {
5 - setX(e.target.value);
6 - });
7 - const object = { x, onChange };
8 - return useMemo(() => {
9 - const { x, onChange } = object;
10 - return <input value={x} onChange={onChange} />;
11 - }, [x]);
12 -}