fix: preserve structural sharing for no-op array-methods calls
Before adoption: this commit came in with the history the project adopted, so no landing records it.
The enableArrayMethods() plugin routed every mutating array method through executeArrayMethod, which unconditionally called markChanged. As a result calls that change nothing - push()/unshift() with no arguments (e.g. the common draft.list.push(...items) with an empty items), splice(i, 0), and pop()/shift() on an empty array - produced a new state reference, breaking the structural-sharing guarantee that native Immer keeps (produce returning the base when nothing changed). Detect these no-ops in O(1) and skip marking the array changed, so the producer returns the base and emits no patches, matching core behavior.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Signed-off-by: maximilliangrand <214999687+maximilliangrand@users.noreply.github.com>
Diff stats
2 files+88 added−16 removed
- tests:+38 added−0 removed
- other:+50 added−16 removed