SIGN IN SIGN UP
immerjs / immer UNCLAIMED

Create the next immutable state by mutating the current one

0 0 58 JavaScript

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)

BREAKING CHANGE: enable loose iteration by default

* Simplify some iteration checks
* Allow passing type to get/set utils to skip archetype lookup
* Convert assigned_ to Map
* Enable loose iteration
* Replace recursive tree finalization with targeted callbacks

Ported Mutative's "finalization callback" approach as a more targeted and performant implementation for finalization compared to the existing recursive tree traversal approach:

- Added cleanup callbacks for each draft that's created
- Added callbacks to handle root drafts, assigned values, and recursing
  inside of plain values
- Updated state creation to return [draft, state] to avoid a lookup
- Rewrote patch generation system to work with callbacks instead of
  during tree traversal

* Update self-reference test with new behavior
* Apply code review suggestions
* Byte-shave scopes and patch plugin usage
* Inline finalizeAssigned
* Move fixPotentialSetContents to plugin
* Byte-shave typeof utils
* Byte-shave Object references
* Byte-shave field names and arrow functions
M
Mark Erikson committed
d6c12028c05c1f7bbbdba0e3978b7c06988aa7f2
Parent: 521d5ed
Committed by GitHub <noreply@github.com> on 11/23/2025, 10:00:13 AM