Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix PersistentHashSet.fromArray, was using old sparse array logic, ad…

…d tests
  • Loading branch information...
commit 42f8b1cfab0c6dd1f75b4972ae3290ff81338a40 1 parent 2a2e5df
@swannodette swannodette authored
View
3  src/clj/cljs/core.clj
@@ -1345,7 +1345,8 @@
(defmacro hash-set
([] `cljs.core.PersistentHashSet.EMPTY)
([& xs]
- (if (core/and (every? #(= (:op %) :constant)
+ (if (core/and (core/<= (count xs) 8)
+ (every? #(= (:op %) :constant)
(map #(cljs.analyzer/analyze &env %) xs))
(= (count (into #{} xs)) (count xs)))
`(cljs.core.PersistentHashSet. nil
View
2  src/cljs/cljs/core.cljs
@@ -6136,7 +6136,7 @@ reduces them without incurring seq initialization"
(loop [i 0
out (transient cljs.core.PersistentHashSet.EMPTY)]
(if (< i len)
- (recur (+ i 2) (-conj! out (aget items i)))
+ (recur (inc i) (-conj! out (aget items i)))
(-persistent! out)))))))
(deftype TransientHashSet [^:mutable transient-map]
View
8 test/cljs/cljs/core_test.cljs
@@ -2044,5 +2044,13 @@
(assert (true? (object? #js {})))
(assert (false? (object? nil)))
+ (assert
+ (== (count (hash-set [1 4] [2 4] [3 4] [0 3] [1 3] [2 3] [3 3]
+ [0 2] [1 2] [2 2] [3 2] [4 2] [0 1] [1 1]
+ [2 1] [3 1] [1 0] [2 0] [3 0]))
+ (count (list [1 4] [2 4] [3 4] [0 3] [1 3] [2 3] [3 3]
+ [0 2] [1 2] [2 2] [3 2] [4 2] [0 1] [1 1]
+ [2 1] [3 1] [1 0] [2 0] [3 0]))))
+
:ok
)
Please sign in to comment.
Something went wrong with that request. Please try again.