0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-02 12:28:54 -05:00

Optimize d/mapm helper using reduce-kv

This commit is contained in:
Andrey Antukh 2024-01-31 12:56:17 +01:00
parent 893a8992c3
commit 733825edfa

View file

@ -316,9 +316,12 @@
(defn mapm (defn mapm
"Map over the values of a map" "Map over the values of a map"
([mfn] ([mfn]
(map (fn [[key val]] [key (mfn key val)]))) (map (fn [[key val]] (vec2 key (mfn key val)))))
([mfn coll] ([mfn coll]
(into {} (mapm mfn) coll))) (reduce-kv (fn [coll k v]
(assoc coll k (mfn k v)))
coll
coll)))
(defn removev (defn removev
"Returns a vector of the items in coll for which (fn item) returns logical false" "Returns a vector of the items in coll for which (fn item) returns logical false"