Add lightweight optimization to modifiers handling

Mainly using controlled internal mutation when is possible
This commit is contained in:
Andrey Antukh 2023-06-20 11:47:19 +02:00
parent 4a4423da70
commit 3ab67e4545
2 changed files with 103 additions and 33 deletions

View file

@ -377,7 +377,15 @@
(update [_ state]
(assoc state :workspace-modifiers (calculate-modifiers state ignore-constraints ignore-snap-pixel modif-tree params))))))
;; Rotation use different algorithm to calculate children modifiers (and do not use child constraints).
(def ^:private
xf-rotation-shape
(comp
(remove #(get % :blocked false))
(filter #(:rotation (get editable-attrs (:type %))))
(map :id)))
;; Rotation use different algorithm to calculate children
;; modifiers (and do not use child constraints).
(defn set-rotation-modifiers
([angle shapes]
(set-rotation-modifiers angle shapes (-> shapes gsh/shapes->rect grc/rect->center)))
@ -387,11 +395,7 @@
ptk/UpdateEvent
(update [_ state]
(let [objects (wsh/lookup-page-objects state)
ids
(->> shapes
(remove #(get % :blocked false))
(filter #(:rotation (get editable-attrs (:type %))))
(map :id))
ids (sequence xf-rotation-shape shapes)
get-modifier
(fn [shape]