Skip to content
Browse files

use hashcode in macrology of case, to match runtime

  • Loading branch information...
1 parent ef2e762 commit 12646c6941983e40987bef6e82d5cb0a5f096ab7 @richhickey richhickey committed Jan 26, 2014
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/clj/clojure/core.clj
View
9 src/clj/clojure/core.clj
@@ -6083,17 +6083,18 @@
post-switch equivalence checking must not be done (occurs with hash
collisions)."
[expr-sym default tests thens]
- (let [hashes (into1 #{} (map hash tests))]
+ (let [hashcode #(clojure.lang.Util/hash %)
+ hashes (into1 #{} (map hashcode tests))]
(if (== (count tests) (count hashes))
(if (fits-table? hashes)
; compact case ints, no shift-mask
- [0 0 (case-map hash identity tests thens) :compact]
+ [0 0 (case-map hashcode identity tests thens) :compact]
(let [[shift mask] (or (maybe-min-hash hashes) [0 0])]
(if (zero? mask)
; sparse case ints, no shift-mask
- [0 0 (case-map hash identity tests thens) :sparse]
+ [0 0 (case-map hashcode identity tests thens) :sparse]
; compact case ints, with shift-mask
- [shift mask (case-map #(shift-mask shift mask (hash %)) identity tests thens) :compact])))
+ [shift mask (case-map #(shift-mask shift mask (hashcode %)) identity tests thens) :compact])))
; resolve hash collisions and try again
(let [[tests thens skip-check] (merge-hash-collisions expr-sym default tests thens)
[shift mask case-map switch-type] (prep-hashes expr-sym default tests thens)

0 comments on commit 12646c6

Please sign in to comment.
Something went wrong with that request. Please try again.