Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9308,7 +9308,10 @@ reduces them without incurring seq initialization"

ICollection
(-conj [coll o]
(PersistentHashSet. meta (assoc hash-map o nil) nil))
(let [m (-assoc hash-map o nil)]
(if (identical? m hash-map)
coll
(PersistentHashSet. meta m nil))))

IEmptyableCollection
(-empty [coll] (-with-meta (.-EMPTY PersistentHashSet) meta))
Expand Down Expand Up @@ -9345,7 +9348,10 @@ reduces them without incurring seq initialization"

ISet
(-disjoin [coll v]
(PersistentHashSet. meta (-dissoc hash-map v) nil))
(let [m (-dissoc hash-map v)]
(if (identical? m hash-map)
coll
(PersistentHashSet. meta m nil))))

IFn
(-invoke [coll k]
Expand Down Expand Up @@ -9463,7 +9469,10 @@ reduces them without incurring seq initialization"

ICollection
(-conj [coll o]
(PersistentTreeSet. meta (assoc tree-map o nil) nil))
(let [m (-assoc tree-map o nil)]
(if (identical? m tree-map)
coll
(PersistentTreeSet. meta m nil))))

IEmptyableCollection
(-empty [coll] (PersistentTreeSet. meta (-empty tree-map) 0))
Expand Down Expand Up @@ -9517,7 +9526,10 @@ reduces them without incurring seq initialization"

ISet
(-disjoin [coll v]
(PersistentTreeSet. meta (dissoc tree-map v) nil))
(let [m (-dissoc tree-map v)]
(if (identical? m tree-map)
coll
(PersistentTreeSet. meta m nil))))

IFn
(-invoke [coll k]
Expand Down Expand Up @@ -13002,7 +13014,10 @@ reduces them without incurring seq initialization"

ISet
(-disjoin [coll v]
(Set. meta (-dissoc hash-map v) nil))
(let [new-hash-map (-dissoc hash-map v)]
(if (identical? new-hash-map hash-map)
coll
(Set. meta new-hash-map nil))))

IEditableCollection
(-as-transient [coll]
Expand Down
21 changes: 21 additions & 0 deletions src/test/cljs/cljs/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,27 @@
(is (= #{1 2} (hash-set 1 2 2)))
(is (= #{1 2} (apply hash-set [1 2 2]))))

(deftest test-ordered-set
(is (= #{1 2} (sorted-set 1 2 2)))
(is (= [1 2 3] (seq (sorted-set 2 3 1))))
(is (= #{1 2} (apply sorted-set [1 2 2]))))

(deftest test-3454-conj
(is (= #{1 2 3} (conj #{1 2} 3)))
(is (= #{1 2 3} (conj (sorted-set 1 2) 3)))
(let [s #{1 2}
ss (sorted-set 1 2)]
(is (identical? s (conj s 2)))
(is (identical? ss (conj ss 2)))))

(deftest test-3454-disj
(is (= #{1 2} (disj #{1 2 3} 3)))
(is (= #{1 2} (disj (sorted-set 1 2 3) 3)))
(let [s #{1 2}
ss (sorted-set 1 2)]
(is (identical? s (disj s 3)))
(is (identical? ss (disj ss 3)))))

(deftest test-585
(is (= (last (map identity (into [] (range 32)))) 31))
(is (= (into #{} (range 32))
Expand Down