Skip to content

Commit 12646c6

Browse files
committed
use hashcode in macrology of case, to match runtime
1 parent ef2e762 commit 12646c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/clj/clojure/core.clj

+5-4
Original file line numberDiff line numberDiff line change
@@ -6083,17 +6083,18 @@
60836083
post-switch equivalence checking must not be done (occurs with hash
60846084
collisions)."
60856085
[expr-sym default tests thens]
6086-
(let [hashes (into1 #{} (map hash tests))]
6086+
(let [hashcode #(clojure.lang.Util/hash %)
6087+
hashes (into1 #{} (map hashcode tests))]
60876088
(if (== (count tests) (count hashes))
60886089
(if (fits-table? hashes)
60896090
; compact case ints, no shift-mask
6090-
[0 0 (case-map hash identity tests thens) :compact]
6091+
[0 0 (case-map hashcode identity tests thens) :compact]
60916092
(let [[shift mask] (or (maybe-min-hash hashes) [0 0])]
60926093
(if (zero? mask)
60936094
; sparse case ints, no shift-mask
6094-
[0 0 (case-map hash identity tests thens) :sparse]
6095+
[0 0 (case-map hashcode identity tests thens) :sparse]
60956096
; compact case ints, with shift-mask
6096-
[shift mask (case-map #(shift-mask shift mask (hash %)) identity tests thens) :compact])))
6097+
[shift mask (case-map #(shift-mask shift mask (hashcode %)) identity tests thens) :compact])))
60976098
; resolve hash collisions and try again
60986099
(let [[tests thens skip-check] (merge-hash-collisions expr-sym default tests thens)
60996100
[shift mask case-map switch-type] (prep-hashes expr-sym default tests thens)

0 commit comments

Comments
 (0)