🐛 Carry no geometry a switched copy already shows within precision

A switch carries the touched attributes of the old copy into the new
one, skipping those whose values are already equal. Geometry was compared
exactly: a turn the new copy already showed, up to float noise in its
transform, was carried and marked as a geometry override the old copy
did not author.

Geometry attributes compare within their precision, as the check that
both variants share a value already does.

Benchmark (scripts/bench-components, ms, lower 2.5% quantile):

| world                              | baseline |     now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels  |   35.215 |  18.972 |  0.54 |
| edit-through-a-chain-of-dependents |   68.931 |   37.79 |  0.55 |
| library-update-into-copies         |   83.083 |  46.453 |  0.56 |
| main-edit-among-many-shapes        |    4.837 |   2.175 |  0.45 |
| main-edit-into-10-copies           |     1.79 |   0.927 |  0.52 |
| main-edit-into-100-copies          |   15.415 |    8.87 |  0.58 |
| main-edit-into-1000-copies         |  153.086 |  89.777 |  0.59 |
| variant-switch-into-copies         |   32.052 |  20.379 |  0.64 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-05 23:41:21 +01:00
parent 2c918644d1
commit da44e9ee50
2 changed files with 18 additions and 2 deletions

View File

@ -175,8 +175,11 @@
;; If the attribute is not valid for the destiny, don't copy it
(not (cts/is-allowed-switch-keep-attr? attr (:type current-shape)))
;; If the values are already equal, don't copy them
(= (get previous-shape attr) (get current-shape attr))
;; If the values are already equal, don't copy them; geometry
;; within its precision
(if (= sync-group :geometry-group)
(gsh/close-attrs? attr (get previous-shape attr) (get current-shape attr))
(= (get previous-shape attr) (get current-shape attr)))
;; If :selrect/:points values are already equal ignoring displacement,
;; don't copy them

View File

@ -1197,3 +1197,16 @@
:layout-item-margins false :grid-square false :rich-variants true
:layout-children false :grid-empty true :layout-copies true :text true}]
:ops [[:style 0 29 1] [:nest 9 0 0 0] [:duplicate 5 1 0 0]]})))))
(t/deftest generated-switch-carries-no-geometry-the-new-copy-already-shows
;; a switched head inherits a turn its new copy already shows up to float
;; noise in the transform; the switch carries no geometry override for it
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :layout-item-margins false
:grid-square false :library true :rich-variants true :layout-children false
:grid-empty false :layout-copies true :text true}]
:ops [[:nest 6 0 0 0] [:rotate 21 0 0 0] [:duplicate 21 0 0 0] [:switch 0 0 0 0]
[:switch 0 0 0 0] [:edit 6 0 1 1] [:update-main 6] [:switch 9 0 0 0]]})))
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff false
:layout-item-margins false :grid-square false :rich-variants true
:layout-children false :grid-empty false :layout-copies true :text true}]
:ops [[:rotate 0 0 0 0] [:update-main 0 0 0 0] [:resize 0 0 0 0] [:switch 4 0 0 0]]}))))