Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enhance hash function to be compatible with Clojure 1.6

  • Loading branch information...
commit 515c8607f6472bdcad3443600761b7229ded1f4d 1 parent 93ec698
@jafingerhut jafingerhut authored
Showing with 13 additions and 1 deletion.
  1. +2 −1  project.clj
  2. +11 −0 src/immutable_bitset.clj
View
3  project.clj
@@ -7,7 +7,8 @@
:profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]
[criterium "0.4.1"]
[reiddraper/simple-check "0.5.1"]
- [collection-check "0.1.1-SNAPSHOT"]]}}
+ [collection-check "0.1.1-SNAPSHOT"]]}
+ :1.6 {:dependencies [[org.clojure/clojure "1.6.0-beta1"]]}}
:test-selectors {:default (complement :benchmark)
:benchmark :benchmark}
:jvm-opts ^:replace ["-server"])
View
11 src/immutable_bitset.clj
@@ -52,6 +52,11 @@
cnt#
(p/inc cnt#))))
+(defmacro compile-if [test then else]
+ (if (eval test)
+ then
+ else))
+
(deftype PersistentBitSet
[^byte log2-chunk-size
^int generation
@@ -68,6 +73,12 @@
(reduce #(p/+ (long %1) (long %2))))))
(equals [this x] (.equiv this x))
+ clojure.lang.IHashEq
+ (hasheq [this]
+ (compile-if (resolve 'clojure.core/hash-unordered-coll)
+ (hash-unordered-coll this)
+ (.hashCode this)))
+
java.util.Set
(size [this] (count this))
(isEmpty [this] (zero? (count this)))
Please sign in to comment.
Something went wrong with that request. Please try again.