Skip to content

Commit 9114d25

Browse files
committed
CLJS-3354: map-invert should use transients and reduce-kv instead of reduce
1 parent d61bb65 commit 9114d25

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/cljs/clojure/set.cljs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@
9696

9797
(defn map-invert
9898
"Returns the map with the vals mapped to the keys."
99-
[m] (reduce (fn [m [k v]] (assoc m v k)) {} m))
99+
[m]
100+
(persistent!
101+
(reduce-kv (fn [m k v] (assoc! m v k))
102+
(transient {})
103+
m)))
100104

101105
(defn join
102106
"When passed 2 rels, returns the rel corresponding to the natural

0 commit comments

Comments
 (0)