mirror of
https://github.com/penpot/penpot.git
synced 2026-05-24 16:38:40 -04:00
⚡ Skip grid reorder and changed-attrs walk on translation commits
This commit is contained in:
@@ -75,7 +75,7 @@
|
||||
(reduce check-shape changes mod-obj-changes)))
|
||||
|
||||
(defn generate-update-shapes
|
||||
[changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects?]}]
|
||||
[changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects? translation?]}]
|
||||
(let [changes (reduce
|
||||
(fn [changes id]
|
||||
(let [opts {:attrs attrs
|
||||
@@ -86,13 +86,19 @@
|
||||
(-> changes
|
||||
(pcb/with-objects objects))
|
||||
ids)
|
||||
grid-ids (->> ids (filter (partial ctl/grid-layout? objects)))
|
||||
changes (-> changes
|
||||
(pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true})
|
||||
(pcb/reorder-grid-children ids)
|
||||
(cond->
|
||||
(not ignore-touched)
|
||||
(generate-unapply-tokens objects changed-sub-attr)))]
|
||||
;; Translation doesn't shift children between grid cells, so
|
||||
;; cell reassignment + child reorder are no-ops with a per-grid
|
||||
;; cost. Skipping them on translation-only commits removes the
|
||||
;; grid-layout reflow from the on-drop hot path.
|
||||
grid-ids (when-not translation?
|
||||
(->> ids (filter (partial ctl/grid-layout? objects))))
|
||||
changes (cond-> changes
|
||||
(seq grid-ids)
|
||||
(-> (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true})
|
||||
(pcb/reorder-grid-children ids))
|
||||
|
||||
(not ignore-touched)
|
||||
(generate-unapply-tokens objects changed-sub-attr))]
|
||||
changes))
|
||||
|
||||
(defn- generate-update-shape-flags
|
||||
|
||||
@@ -73,9 +73,16 @@
|
||||
(filter #(some update-layout-attr? (pcb/changed-attrs % objects update-fn {:attrs attrs :with-objects? with-objects?})))
|
||||
(map :id))
|
||||
|
||||
;; `xf-update-layout` runs `update-fn` + attr diff for
|
||||
;; every id just to decide whether to dispatch
|
||||
;; `:layout/update`. `update-layout-attr?` is `#{:hidden}`,
|
||||
;; so a pure-translation commit can never trigger it —
|
||||
;; skip the N×diff walk on drop-of-layout-drag (the hot
|
||||
;; on-drop path for layouts with many children).
|
||||
update-layout-ids
|
||||
(->> (into [] xf-update-layout ids)
|
||||
(not-empty))
|
||||
(when-not translation?
|
||||
(->> (into [] xf-update-layout ids)
|
||||
(not-empty)))
|
||||
|
||||
changes
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
@@ -88,7 +95,8 @@
|
||||
:changed-sub-attr changed-sub-attr
|
||||
:ignore-tree ignore-tree
|
||||
:ignore-touched ignore-touched
|
||||
:with-objects? with-objects?})
|
||||
:with-objects? with-objects?
|
||||
:translation? translation?})
|
||||
(cond-> undo-group
|
||||
(pcb/set-undo-group undo-group))
|
||||
(pcb/set-translation? translation?))
|
||||
|
||||
Reference in New Issue
Block a user