Andrey Antukh 17d4d92e1d ⚡ Fuse the reg-objects of a change batch per container
The component sync emits a `:reg-objects` for the parents of every
shape it touches, so a component swap collected 291 of them for 36
containers. Recomputing a group's geometry N times in a row gives the
same result as doing it once, so most of that work was thrown away,
in the browser and on the server, on every save.

`mch/merge-reg-objects` collapses them into one per container, with
the union of the shapes. The merged change moves to the end of the
batch: a group has to be recomputed after the shapes that resized
it, not before, or it keeps a stale `:selrect` until something else
touches it. That is also why it must not stay in the position of the
first change it replaces.

It runs on every commit, redo and undo alike, so the undo stack gets
the same benefit, and again when the buffer is batched for saving.
Measured on the swap that motivated this: 291 `:reg-objects` become
36, and the batch goes from 806 changes / 6.4 MB to 551 / 324 KB.

AI-assisted-by: space-bunny
2026-10-13 21:05:51 +02:00
..