dillon1000/react

Commit

Dramatically simplify InlineUseMemo

I realized a wayyyy simpler approach to inlining a lambda: wrap it in a labeled 
block. The transformation is roughly as follows: 

```javascript 

// Before 

const x = useMemo(() => { 

if (a) { 

return b; 

} 

return c; 

}, [a, b, c]); 

return x; 

// After 

let x; 

label: { 

if (a) { 

x = b; 

break label; 

} 

x = c; 

break label; 

} 

return x; 

``` 

The key to making this work is fixing up some edge cases in labeled blocks, 
hence the previous PRs.
Browse files
Changed paths5 files
First-parent comparison
M compiler/forget/src/Inference/InlineUseMemo.ts ModifiedM compiler/forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/compiler/useMemo-switch-no-fallthrough.expect.md Modified
Patch

Files changed

Rendering syntax-highlighted changes…