Skip to content

Commit e173e54

Browse files
thosmosswannodette
authored andcommitted
CLJS-844: Optimize js->clj by switching to transients
1 parent c2b864d commit e173e54

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10595,15 +10595,17 @@ reduces them without incurring seq initialization"
1059510595
(MapEntry. (thisfn (key x)) (thisfn (val x)) nil)
1059610596

1059710597
(coll? x)
10598-
(into (empty x) (map thisfn x))
10598+
(into (empty x) (map thisfn) x)
1059910599

1060010600
(array? x)
10601-
(vec (map thisfn x))
10601+
(persistent!
10602+
(reduce #(conj! %1 (thisfn %2))
10603+
(transient []) x))
1060210604

1060310605
(identical? (type x) js/Object)
10604-
(into {} (for [k (js-keys x)]
10605-
[(keyfn k) (thisfn (unchecked-get x k))]))
10606-
10606+
(persistent!
10607+
(reduce (fn [r k] (assoc! r (keyfn k) (thisfn (gobject/get x k))))
10608+
(transient {}) (js-keys x)))
1060710609
:else x))]
1060810610
(f x))))
1060910611

0 commit comments

Comments
 (0)