Skip to content

Commit 7e87659

Browse files
jafingerhutstuarthalloway
authored andcommitted
CLJ-1331: Update primitive vectors to use Murmur3 hash
Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent 010fb51 commit 7e87659

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/clj/clojure/gvec.clj

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
(in-ns 'clojure.core)
1212

13+
(import '(clojure.lang Murmur3))
14+
1315
;(set! *warn-on-reflection* true)
1416

1517
(deftype VecNode [edit arr])
@@ -145,6 +147,11 @@
145147
(clojure.lang.Util/hash val))
146148
(inc i))))))
147149

150+
;todo - cache
151+
clojure.lang.IHashEq
152+
(hasheq [this]
153+
(Murmur3/hashOrdered this))
154+
148155
clojure.lang.Counted
149156
(count [_] cnt)
150157

test/clojure/test_clojure/vectors.clj

+3-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@
327327
(vector-of ""))))
328328
(testing "vector-like (vector-of :type x1 x2 x3 … xn)"
329329
(are [vec gvec] (and (instance? clojure.core.Vec gvec)
330-
(= (into (vector-of :int) vec) gvec))
330+
(= (into (vector-of :int) vec) gvec)
331+
(= vec gvec)
332+
(= (hash vec) (hash gvec)))
331333
[1] (vector-of :int 1)
332334
[1 2] (vector-of :int 1 2)
333335
[1 2 3] (vector-of :int 1 2 3)

0 commit comments

Comments
 (0)