You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=false > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
12
12
13
-
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=false > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
14
-
15
13
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=false > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
16
14
17
15
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=false > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=true > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
50
48
51
-
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=true > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
52
-
53
49
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=true > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
54
50
55
51
exports[`base functionality - auto-freeze=false:shallow-copy=false:use-listener=true > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=false > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
88
84
89
-
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=false > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
90
-
91
85
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=false > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
92
86
93
87
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=false > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=true > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
126
120
127
-
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=true > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
128
-
129
121
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=true > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
130
122
131
123
exports[`base functionality - auto-freeze=false:shallow-copy=true:use-listener=true > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=false > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
164
156
165
-
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=false > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
166
-
167
157
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=false > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
168
158
169
159
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=false > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=true > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
202
192
203
-
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=true > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
204
-
205
193
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=true > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
206
194
207
195
exports[`base functionality - auto-freeze=true:shallow-copy=false:use-listener=true > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=false > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
240
228
241
-
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=false > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
242
-
243
229
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=false > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
244
230
245
231
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=false > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=true > recipe functions > cannot return a modified child draft 1`] =`[Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.]`;
278
264
279
-
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=true > recipe functions > cannot return an object that references itself 1`] =`[Error: [Immer] Immer forbids circular references]`;
280
-
281
265
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=true > revokes the draft once produce returns 1`] =`[TypeError: Cannot perform 'get' on a proxy that has been revoked]`;
282
266
283
267
exports[`base functionality - auto-freeze=true:shallow-copy=true:use-listener=true > revokes the draft once produce returns 2`] =`[TypeError: Cannot perform 'set' on a proxy that has been revoked]`;
0 commit comments