mirror of
https://github.com/penpot/penpot.git
synced 2026-09-18 18:06:14 +00:00
⚡ Remove unnecesary index building on :mov-objects
This commit is contained in:
parent
96af4e26b0
commit
2befad433f
@ -225,8 +225,8 @@
|
|||||||
(-> (update :touched cph/set-touched-group :shapes-group)
|
(-> (update :touched cph/set-touched-group :shapes-group)
|
||||||
(dissoc :remote-synced?)))))
|
(dissoc :remote-synced?)))))
|
||||||
|
|
||||||
(remove-from-old-parent [cpindex objects shape-id]
|
(remove-from-old-parent [old-objects objects shape-id]
|
||||||
(let [prev-parent-id (get cpindex shape-id)]
|
(let [prev-parent-id (dm/get-in old-objects [shape-id :parent-id])]
|
||||||
;; Do nothing if the parent id of the shape is the same as
|
;; Do nothing if the parent id of the shape is the same as
|
||||||
;; the new destination target parent id.
|
;; the new destination target parent id.
|
||||||
(if (= prev-parent-id parent-id)
|
(if (= prev-parent-id parent-id)
|
||||||
@ -263,17 +263,6 @@
|
|||||||
|
|
||||||
(move-objects [objects]
|
(move-objects [objects]
|
||||||
(let [valid? (every? (partial is-valid-move? objects) shapes)
|
(let [valid? (every? (partial is-valid-move? objects) shapes)
|
||||||
|
|
||||||
;; Create a index of shape ids pointing to the
|
|
||||||
;; corresponding parents; used mainly for update old
|
|
||||||
;; parents after move operation.
|
|
||||||
cpindex (reduce (fn [index id]
|
|
||||||
(let [obj (get objects id)]
|
|
||||||
(assoc! index id (:parent-id obj))))
|
|
||||||
(transient {})
|
|
||||||
(keys objects))
|
|
||||||
cpindex (persistent! cpindex)
|
|
||||||
|
|
||||||
parent (get objects parent-id)
|
parent (get objects parent-id)
|
||||||
frame-id (if (= :frame (:type parent))
|
frame-id (if (= :frame (:type parent))
|
||||||
(:id parent)
|
(:id parent)
|
||||||
@ -290,7 +279,7 @@
|
|||||||
;; Analyze the old parents and clear the old links
|
;; Analyze the old parents and clear the old links
|
||||||
;; only if the new parent is different form old
|
;; only if the new parent is different form old
|
||||||
;; parent.
|
;; parent.
|
||||||
(reduce (partial remove-from-old-parent cpindex) $ shapes)
|
(reduce (partial remove-from-old-parent objects) $ shapes)
|
||||||
|
|
||||||
;; Ensure that all shapes of the new parent has a
|
;; Ensure that all shapes of the new parent has a
|
||||||
;; correct link to the topside frame.
|
;; correct link to the topside frame.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user