mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
⚡ Optimize set-shape-svg-attrs by removing redundant operations
- Remove backward compatibility for kebab-case SVG attribute keys (fill-rule, stroke-linecap, stroke-linejoin) since svg-attrs are already normalized to camelCase by the attrs->props migration. - Remove unnecessary select-keys filtering and intermediate map construction (dissoc :style + merge style). - Directly extract values from style and attrs using or, avoiding any intermediate map allocation. Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
348b263ffb
commit
735877756d
@ -571,16 +571,10 @@
|
|||||||
(defn set-shape-svg-attrs
|
(defn set-shape-svg-attrs
|
||||||
[attrs]
|
[attrs]
|
||||||
(let [style (:style attrs)
|
(let [style (:style attrs)
|
||||||
;; Filter to only supported attributes
|
fill-rule (-> (or (:fillRule style) (:fillRule attrs)) sr/translate-fill-rule)
|
||||||
allowed-keys #{:fill :fillRule :fill-rule :strokeLinecap :stroke-linecap :strokeLinejoin :stroke-linejoin}
|
stroke-linecap (-> (or (:strokeLinecap style) (:strokeLinecap attrs)) sr/translate-stroke-linecap)
|
||||||
attrs (-> attrs
|
stroke-linejoin (-> (or (:strokeLinejoin style) (:strokeLinejoin attrs)) sr/translate-stroke-linejoin)
|
||||||
(dissoc :style)
|
fill-none (= "none" (or (:fill style) (:fill attrs)))]
|
||||||
(merge style)
|
|
||||||
(select-keys allowed-keys))
|
|
||||||
fill-rule (-> (or (:fill-rule attrs) (:fillRule attrs)) sr/translate-fill-rule)
|
|
||||||
stroke-linecap (-> (or (:stroke-linecap attrs) (:strokeLinecap attrs)) sr/translate-stroke-linecap)
|
|
||||||
stroke-linejoin (-> (or (:stroke-linejoin attrs) (:strokeLinejoin attrs)) sr/translate-stroke-linejoin)
|
|
||||||
fill-none (= "none" (-> attrs :fill))]
|
|
||||||
(h/call wasm/internal-module "_set_shape_svg_attrs" fill-rule stroke-linecap stroke-linejoin fill-none)))
|
(h/call wasm/internal-module "_set_shape_svg_attrs" fill-rule stroke-linecap stroke-linejoin fill-none)))
|
||||||
|
|
||||||
(defn set-shape-path-content
|
(defn set-shape-path-content
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user