We're updating the issue view to help you get more done. 

PersistentArrayMap's assoc doesn't respect HASHTABLE_THRESHOLD

Description

Currently a map with more than 8 elements will be converted from a PersistentArrayMap to a PersistentHashMap, but if using assoc, it will take 9 elements before the conversion happens:

1 2 3 4 5 6 7 8 user=> (class {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7}) clojure.lang.PersistentArrayMap user=> (class {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) clojure.lang.PersistentHashMap user=> (class (assoc {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7} 8 8)) clojure.lang.PersistentArrayMap user=> (class (assoc {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7} 8 8 9 9)) clojure.lang.PersistentHashMap

After patch:

1 2 3 4 5 6 7 8 user=> (class {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7}) clojure.lang.PersistentArrayMap user=> (class {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) clojure.lang.PersistentHashMap user=> (class (assoc {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7} 8 8)) clojure.lang.PersistentHashMap user=> (class (assoc {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7} 8 8 9 9)) clojure.lang.PersistentHashMap

Patch: 0001-PersistentArrayMap-s-assoc-doesn-t-respect-HASHTABLE.patch

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

Nicola Mometto

Approval

Ok

Patch

Code

Fix versions

Priority

Minor