mirror of
https://github.com/penpot/penpot.git
synced 2025-05-14 19:36:38 +02:00
Merge pull request #1914 from penpot/alotor-performance-improvements
Performance improvements
This commit is contained in:
commit
fa00d674eb
3 changed files with 63 additions and 45 deletions
|
@ -176,6 +176,11 @@
|
||||||
|
|
||||||
(defn calc-child-modifiers
|
(defn calc-child-modifiers
|
||||||
[parent child modifiers ignore-constraints transformed-parent-rect]
|
[parent child modifiers ignore-constraints transformed-parent-rect]
|
||||||
|
|
||||||
|
(if (and (nil? (:resize-vector modifiers))
|
||||||
|
(nil? (:resize-vector-2 modifiers)))
|
||||||
|
;; If we don't have a resize modifier we return the same modifiers
|
||||||
|
modifiers
|
||||||
(let [constraints-h
|
(let [constraints-h
|
||||||
(if-not ignore-constraints
|
(if-not ignore-constraints
|
||||||
(:constraints-h child (default-constraints-h child))
|
(:constraints-h child (default-constraints-h child))
|
||||||
|
@ -217,4 +222,4 @@
|
||||||
:resize-transform-inverse (:resize-transform-inverse modifiers))
|
:resize-transform-inverse (:resize-transform-inverse modifiers))
|
||||||
|
|
||||||
:always
|
:always
|
||||||
(clean-modifiers))))
|
(clean-modifiers)))))
|
||||||
|
|
|
@ -356,22 +356,27 @@
|
||||||
[modif-tree shape modifiers]
|
[modif-tree shape modifiers]
|
||||||
|
|
||||||
(let [children (map (d/getf objects) (:shapes shape))
|
(let [children (map (d/getf objects) (:shapes shape))
|
||||||
modifiers (cond-> modifiers snap-pixel? (set-pixel-precision shape))
|
|
||||||
transformed-rect (gsh/transform-selrect (:selrect shape) modifiers)
|
transformed-rect (gsh/transform-selrect (:selrect shape) modifiers)
|
||||||
|
|
||||||
set-child
|
set-child
|
||||||
(fn [modif-tree child]
|
(fn [snap-pixel? modif-tree child]
|
||||||
(let [child-modifiers (gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)]
|
(let [child-modifiers (gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)
|
||||||
|
child-modifiers (cond-> child-modifiers snap-pixel? (set-pixel-precision child))]
|
||||||
(cond-> modif-tree
|
(cond-> modif-tree
|
||||||
(not (gsh/empty-modifiers? child-modifiers))
|
(not (gsh/empty-modifiers? child-modifiers))
|
||||||
(set-modifiers-rec child child-modifiers))))
|
(set-modifiers-rec child child-modifiers))))
|
||||||
|
|
||||||
modif-tree
|
modif-tree
|
||||||
(-> modif-tree
|
(-> modif-tree
|
||||||
(assoc-in [(:id shape) :modifiers] modifiers))]
|
(assoc-in [(:id shape) :modifiers] modifiers))
|
||||||
|
|
||||||
(reduce set-child modif-tree children)))]
|
resize-modif?
|
||||||
(set-modifiers-rec modif-tree shape modifiers)))
|
(or (:resize-vector modifiers) (:resize-vector-2 modifiers))]
|
||||||
|
|
||||||
|
(reduce (partial set-child (and snap-pixel? resize-modif?)) modif-tree children)))]
|
||||||
|
|
||||||
|
(let [modifiers (cond-> modifiers snap-pixel? (set-pixel-precision shape))]
|
||||||
|
(set-modifiers-rec modif-tree shape modifiers))))
|
||||||
|
|
||||||
(defn- get-ignore-tree
|
(defn- get-ignore-tree
|
||||||
"Retrieves a map with the flag `ignore-geometry?` given a tree of modifiers"
|
"Retrieves a map with the flag `ignore-geometry?` given a tree of modifiers"
|
||||||
|
|
|
@ -28,9 +28,12 @@
|
||||||
(defn strip-position-data [shape]
|
(defn strip-position-data [shape]
|
||||||
(dissoc shape :position-data :transform :transform-inverse))
|
(dissoc shape :position-data :transform :transform-inverse))
|
||||||
|
|
||||||
|
(defn strip-modifier
|
||||||
|
[modifier]
|
||||||
|
(d/update-when modifier :modifiers dissoc :displacement :rotation))
|
||||||
|
|
||||||
(defn process-shape [modifiers {:keys [id] :as shape}]
|
(defn process-shape [modifiers {:keys [id] :as shape}]
|
||||||
(let [modifier (get modifiers id)
|
(let [modifier (-> (get modifiers id) strip-modifier)
|
||||||
modifier (d/update-when modifier :modifiers dissoc :displacement :rotation)
|
|
||||||
shape (cond-> shape
|
shape (cond-> shape
|
||||||
(not (gsh/empty-modifiers? (:modifiers modifier)))
|
(not (gsh/empty-modifiers? (:modifiers modifier)))
|
||||||
(-> (assoc :grow-type :fixed)
|
(-> (assoc :grow-type :fixed)
|
||||||
|
@ -117,11 +120,16 @@
|
||||||
text-change?
|
text-change?
|
||||||
(fn [id]
|
(fn [id]
|
||||||
(let [old-shape (get prev-text-shapes id)
|
(let [old-shape (get prev-text-shapes id)
|
||||||
new-shape (get text-shapes id)]
|
new-shape (get text-shapes id)
|
||||||
|
old-modifiers (-> (get prev-modifiers id) strip-modifier)
|
||||||
|
new-modifiers (-> (get modifiers id) strip-modifier)]
|
||||||
(or (and (not (identical? old-shape new-shape))
|
(or (and (not (identical? old-shape new-shape))
|
||||||
(not= old-shape new-shape))
|
(not= old-shape new-shape))
|
||||||
(not= (get modifiers id)
|
|
||||||
(get prev-modifiers id)))))
|
;; The shape has changed only if its modifier is not empty and it's different
|
||||||
|
(and (not= new-modifiers old-modifiers)
|
||||||
|
(or (not (gsh/empty-modifiers? (:modifiers old-modifiers)))
|
||||||
|
(not (gsh/empty-modifiers? (:modifiers new-modifiers))))))))
|
||||||
|
|
||||||
changed-texts
|
changed-texts
|
||||||
(mf/use-memo
|
(mf/use-memo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue