dillon1000/react
Commit
Browse files Ensure member path assignments memoize independently
Assignment expressions to a member path are a special case because they're the
only place where a value isn't assigned to a (possibly temporary) variable,
which is our unit of memoization. #901 demonstrated how this can lead to values
that can't be independently memoized:
```javascript
const x = {a: a}
x.y = [b, c]; // array recomputed w `x`, even if only `a` changed
```
This PR ensures that assignment expressions where the LHS is a member path lower
the RHS to a Place. That means the above example is handled as if you wrote:
```javascript
const x = {a: a};
const tmp1 = [b, c];
x.y = tmp1;
```
And we independently memoize the temporary.Changed paths6 files
First-parent comparisoncompiler/forget/src/HIR/BuildHIR.ts ModifiedD compiler/forget/src/__tests__/fixtures/hir/_bug_independently-memoize-object-property.expect.md DeletedD compiler/forget/src/__tests__/fixtures/hir/_bug_independently-memoize-object-property.js DeletedM compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md ModifiedA compiler/forget/src/__tests__/fixtures/hir/independently-memoize-object-property.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/independently-memoize-object-property.js AddedPatch
Files changed
Rendering syntax-highlighted changes…