Skip to content

Commit fb14b18

Browse files
thomasmulvaneydnolen
authored andcommitted
CLJS-2108: faster set equivalence
Use backing maps IKVReduce to avoid making seqs and entry objects.
1 parent 13faa48 commit fb14b18

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8662,8 +8662,10 @@ reduces them without incurring seq initialization"
86628662
(and
86638663
(set? other)
86648664
(== (count coll) (count other))
8665-
(every? #(contains? coll %)
8666-
other)))
8665+
^boolean
8666+
(reduce-kv
8667+
#(or (contains? other %2) (reduced false))
8668+
true hash-map)))
86678669

86688670
IHash
86698671
(-hash [coll] (caching-hash coll hash-unordered-coll __hash))
@@ -8811,8 +8813,10 @@ reduces them without incurring seq initialization"
88118813
(and
88128814
(set? other)
88138815
(== (count coll) (count other))
8814-
(every? #(contains? coll %)
8815-
other)))
8816+
^boolean
8817+
(reduce-kv
8818+
#(or (contains? other %2) (reduced false))
8819+
true tree-map)))
88168820

88178821
IHash
88188822
(-hash [coll] (caching-hash coll hash-unordered-coll __hash))

0 commit comments

Comments
 (0)