dillon1000/react
Commit
Browse files Optimize DCE for destructuring
In #1287 i implemented basic handling for destructuring in DCE: if any of the pattern values are used, we retained the whole instruction as-is. However, ideally we could prune out unused elements from the pattern. There are pretty simple rules: * ArrayPattern we can eliminate unused elements from the end. * ObjectPattern we can eliminate any unused element, but only if there is no rest element.
Changed paths11 files
First-parent comparisoncompiler/forget/src/Optimization/DeadCodeElimination.ts ModifiedM compiler/forget/src/__tests__/fixtures/hir/destructure-direct-reassignment.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/destructure-direct-reassignment.js ModifiedA compiler/forget/src/__tests__/fixtures/hir/unused-array-middle-element.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/unused-array-middle-element.js AddedA compiler/forget/src/__tests__/fixtures/hir/unused-array-rest-element.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/unused-array-rest-element.js AddedA compiler/forget/src/__tests__/fixtures/hir/unused-object-element-with-rest.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/unused-object-element-with-rest.js AddedA compiler/forget/src/__tests__/fixtures/hir/unused-object-element.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/unused-object-element.js AddedPatch
Files changed
Rendering syntax-highlighted changes…