Skip to content

Commit 4c78017

Browse files
thhellerswannodette
authored andcommitted
CLJS-3200: reduce code generated by destructure macro for maps
1 parent bdbd6c5 commit 4c78017

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3986,6 +3986,11 @@ reduces them without incurring seq initialization"
39863986

39873987
(set! *unchecked-if* false)
39883988

3989+
;; CLJS-3200: used by destructure macro for maps to reduce amount of repeated code
3990+
;; placed here because it needs apply and hash-map (only declared at this point)
3991+
(defn --destructure-map [x]
3992+
(if (implements? ISeq x) (apply cljs.core/hash-map x) x))
3993+
39893994
(defn vary-meta
39903995
"Returns an object of the same type and value as obj, with
39913996
(apply f (meta obj) args) as its metadata."

src/main/clojure/cljs/core.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@
666666
(core/let [gmap (gensym "map__")
667667
defaults (:or b)]
668668
(core/loop [ret (core/-> bvec (conj gmap) (conj v)
669-
(conj gmap) (conj `(if (implements? ISeq ~gmap) (apply cljs.core/hash-map ~gmap) ~gmap))
669+
(conj gmap) (conj `(--destructure-map ~gmap))
670670
((core/fn [ret]
671671
(if (:as b)
672672
(conj ret (:as b) gmap)

0 commit comments

Comments
 (0)