Permalink
Browse files

CLJ-1331: Update primitive vectors to use Murmur3 hash

Signed-off-by: Stuart Halloway <stu@cognitect.com>
  • Loading branch information...
1 parent 010fb51 commit 7e8765912e87c77140bcff87a5f8fad397acc545 @jafingerhut jafingerhut committed with stuarthalloway Feb 4, 2014
Showing with 10 additions and 1 deletion.
  1. +7 −0 src/clj/clojure/gvec.clj
  2. +3 −1 test/clojure/test_clojure/vectors.clj
View
@@ -10,6 +10,8 @@
(in-ns 'clojure.core)
+(import '(clojure.lang Murmur3))
+
;(set! *warn-on-reflection* true)
(deftype VecNode [edit arr])
@@ -145,6 +147,11 @@
(clojure.lang.Util/hash val))
(inc i))))))
+ ;todo - cache
+ clojure.lang.IHashEq
+ (hasheq [this]
+ (Murmur3/hashOrdered this))
+
clojure.lang.Counted
(count [_] cnt)
@@ -327,7 +327,9 @@
(vector-of ""))))
(testing "vector-like (vector-of :type x1 x2 x3 … xn)"
(are [vec gvec] (and (instance? clojure.core.Vec gvec)
- (= (into (vector-of :int) vec) gvec))
+ (= (into (vector-of :int) vec) gvec)
+ (= vec gvec)
+ (= (hash vec) (hash gvec)))
[1] (vector-of :int 1)
[1 2] (vector-of :int 1 2)
[1 2 3] (vector-of :int 1 2 3)

0 comments on commit 7e87659

Please sign in to comment.