Skip to content

Commit 84ec416

Browse files
committed
we need to replicate the compiler logic for sets in lite mode as well
1 parent 06cd9a8 commit 84ec416

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/main/cljs/cljs/core.cljs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13142,7 +13142,20 @@ reduces them without incurring seq initialization"
1314213142
(set! (. SetLite -EMPTY) (SetLite. nil (. HashMapLite -EMPTY) empty-unordered-hash))
1314313143

1314413144
(defn set-lite
13145-
":lite-mode version of set, not intended ot be used directly."
13145+
":lite-mode version of set, not intended to be used directly."
13146+
[coll]
13147+
(if (set? coll)
13148+
(-with-meta coll nil)
13149+
(let [in (seq coll)]
13150+
(if (nil? in)
13151+
#{}
13152+
(loop [in in out (. SetLite -EMPTY)]
13153+
(if-not (nil? in)
13154+
(recur (next in) (conj out (first in)))
13155+
out))))))
13156+
13157+
(defn set-lite-check
13158+
":lite-mode version of set with check, not intended to be used directly."
1314613159
[coll]
1314713160
(if (set? coll)
1314813161
(-with-meta coll nil)

src/main/clojure/cljs/compiler.cljc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,14 @@
617617
:else (emits "cljs.core.PersistentHashSet.createWithCheck([" (comma-sep items) "])")))
618618

619619
(defn emit-lite-set [items comma-sep distinct-constants?]
620-
(if (empty? items)
620+
(cond
621+
(empty? items)
621622
(emits "cljs.core.SetLite.EMPTY")
622-
(emits "cljs.core.set_lite([" (comma-sep items) "])")))
623+
624+
(distinct-constants? items)
625+
(emits "cljs.core.set_lite([" (comma-sep items) "])")
626+
627+
:else (emits "cljs.core.set_lite_check([" (comma-sep items) "])")))
623628

624629
(defmethod emit* :set
625630
[{:keys [items env]}]

0 commit comments

Comments
 (0)