Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fix off-by-one in transient map keyword lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ztellman committed Sep 3, 2014
1 parent d5ab875 commit eb7dfe6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
12 changes: 6 additions & 6 deletions collections/clojure/lang/PersistentUnrolledMap.java
Expand Up @@ -195,27 +195,27 @@ private int indexOf(int h, Object key) {
switch (6 - count) {
case 0:
if (k5 == key) {
return 6;
return 5;
}
case 1:
if (k4 == key) {
return 5;
return 4;
}
case 2:
if (k3 == key) {
return 4;
return 3;
}
case 3:
if (k2 == key) {
return 3;
return 2;
}
case 4:
if (k1 == key) {
return 2;
return 1;
}
case 5:
if (k0 == key) {
return 1;
return 0;
}
default:
return -1;
Expand Down
2 changes: 1 addition & 1 deletion generate/cambrian_collections/map.clj
Expand Up @@ -556,7 +556,7 @@
(fn [idx k]
[idx
(j/cond (str k "== key")
(j/return (- max-cardinality idx)))])
(j/return (- max-cardinality idx 1)))])
(range)
(reverse ks))
[(j/return -1)])))
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -13,7 +13,7 @@
[org.jibx.config.3rdparty.org.eclipse/org.eclipse.text "3.5.100.v20110505-0800"]
[org.jibx.config.3rdparty.org.eclipse/org.eclipse.core.resources "3.7.100.v20110510-0712"]
[org.jibx.config.3rdparty.org.eclipse/org.eclipse.equinox.common "3.6.0.v20110523"]]
:jvm-opts ["-server"]
:jvm-opts ["-server" "-Xmx2g"]
:test-selectors {:default (complement :benchmark)
:benchmark :benchmark}
:main cambrian-collections.main
Expand Down
10 changes: 9 additions & 1 deletion test/cambrian_collections/map_test.clj
Expand Up @@ -15,7 +15,15 @@
(declare unrolled)

(deftest test-map-like
(check/assert-map-like 1e4 (unrolled) gen/int gen/int))
(check/assert-map-like 1e4 (unrolled) gen/int gen/int)
#_(check/assert-map-like 1e3 (unrolled) gen/any gen/int)
(check/assert-map-like 1e3 (unrolled)
(gen/one-of (->> (range (int \a) (int \z))
(map char)
(map str)
(map keyword)
(map gen/return)))
gen/int))

#_(deftest test-print-dup
(binding [*print-dup* true]
Expand Down

0 comments on commit eb7dfe6

Please sign in to comment.