mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 22:41:38 +02:00
⚡ Minor performance enhancement on str concat opetations
And proper stringify of :key prop of react components
This commit is contained in:
parent
f05518e357
commit
4c00c8f3ec
11 changed files with 55 additions and 46 deletions
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.shapes.bool
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.ui.hooks :refer [use-equal-memo]]
|
||||
[app.main.ui.shapes.export :as use]
|
||||
|
@ -45,4 +46,4 @@
|
|||
[:> "penpot:bool" {}
|
||||
(for [item (->> (:shapes shape) (mapv #(get childs %)))]
|
||||
[:& shape-wrapper {:shape item
|
||||
:key (:id item)}])])])))
|
||||
:key (dm/str (:id item))}])])])))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.ui.shapes.frame
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.ui.shapes.attrs :as attrs]
|
||||
[app.util.object :as obj]
|
||||
[debug :refer [debug?]]
|
||||
|
@ -13,12 +14,12 @@
|
|||
|
||||
(defn frame-clip-id
|
||||
[shape render-id]
|
||||
(str "frame-clip-" (:id shape) "-" render-id))
|
||||
(dm/str "frame-clip-" (:id shape) "-" render-id))
|
||||
|
||||
(defn frame-clip-url
|
||||
[shape render-id]
|
||||
(when (= :frame (:type shape))
|
||||
(str "url(#" (frame-clip-id shape render-id) ")")))
|
||||
(dm/str "url(#" (frame-clip-id shape render-id) ")")))
|
||||
|
||||
(mf/defc frame-clip-def
|
||||
[{:keys [shape render-id]}]
|
||||
|
@ -33,7 +34,7 @@
|
|||
(let [shape (obj/get props "shape")]
|
||||
(when (:thumbnail shape)
|
||||
[:image.frame-thumbnail
|
||||
{:id (str "thumbnail-" (:id shape))
|
||||
{:id (dm/str "thumbnail-" (:id shape))
|
||||
:xlinkHref (:thumbnail shape)
|
||||
:x (:x shape)
|
||||
:y (:y shape)
|
||||
|
@ -63,5 +64,5 @@
|
|||
|
||||
(for [item childs]
|
||||
[:& shape-wrapper {:shape item
|
||||
:key (:id item)}])])))
|
||||
:key (dm/str (:id item))}])])))
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.shapes.gradients
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
|
@ -42,7 +43,7 @@
|
|||
|
||||
[:> :linearGradient props
|
||||
(for [{:keys [offset color opacity]} (:stops gradient)]
|
||||
[:stop {:key (str id "-stop-" offset)
|
||||
[:stop {:key (dm/str id "-stop-" offset)
|
||||
:offset (or offset 0)
|
||||
:stop-color color
|
||||
:stop-opacity opacity}])]))
|
||||
|
@ -90,7 +91,7 @@
|
|||
(add-metadata gradient))]
|
||||
[:> :radialGradient props
|
||||
(for [{:keys [offset color opacity]} (:stops gradient)]
|
||||
[:stop {:key (str id "-stop-" offset)
|
||||
[:stop {:key (dm/str id "-stop-" offset)
|
||||
:offset (or offset 0)
|
||||
:stop-color color
|
||||
:stop-opacity opacity}])]))
|
||||
|
@ -101,7 +102,8 @@
|
|||
(let [attr (obj/get props "attr")
|
||||
shape (obj/get props "shape")
|
||||
id (obj/get props "id")
|
||||
id (or id (str (name attr) "_" (mf/use-ctx muc/render-ctx)))
|
||||
id' (mf/use-ctx muc/render-ctx)
|
||||
id (or id (dm/str (name attr) "_" id'))
|
||||
gradient (get shape attr)
|
||||
gradient-props #js {:id id
|
||||
:gradient gradient
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.ui.shapes.group
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.ui.context :as muc]
|
||||
[app.main.ui.shapes.mask :refer [mask-url clip-url mask-factory]]
|
||||
[app.util.object :as obj]
|
||||
|
@ -49,7 +50,7 @@
|
|||
|
||||
(for [item childs]
|
||||
[:& shape-wrapper {:shape item
|
||||
:key (:id item)}])]]))))
|
||||
:key (dm/str (:id item))}])]]))))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.ui.shapes.svg-raw
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.ui.shapes.attrs :as usa]
|
||||
[app.util.object :as obj]
|
||||
|
@ -102,12 +103,12 @@
|
|||
svg-root?
|
||||
[:& svg-root {:shape shape}
|
||||
(for [item childs]
|
||||
[:& shape-wrapper {:shape item :key (:id item)}])]
|
||||
[:& shape-wrapper {:shape item :key (dm/str (:id item))}])]
|
||||
|
||||
svg-tag?
|
||||
[:& svg-element {:shape shape}
|
||||
(for [item childs]
|
||||
[:& shape-wrapper {:shape item :key (:id item)}])]
|
||||
[:& shape-wrapper {:shape item :key (dm/str (:id item))}])]
|
||||
|
||||
svg-leaf?
|
||||
content
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue