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

PersistentHashMap implementation

Description

0001-PersistentHashMap-ported-from-Clojure.patch contains a port of Clojure's PersistentHashMap.

0002-...-.patch rewires cljs.core/hash-map and cljs.compiler/emit's :map method to use cljs.core.PersistentHashMap. With that in place, the regular cljs test suite runs fine.

As a quick sanity check,

1 2 3 4 5 6 7 (loop [m cljs.core.PersistentHashMap/EMPTY i 0] (if (< i 10000) (recur (assoc m i :foo) (inc i)) (loop [i 0] (if (< i 10000) (do (assert (= :foo (get m i))) (recur (inc i)))))))

runs fine under Rhino. Timing this loop produces the expected results: it takes 1.1s on my machine as written above and 10.5s with cljs.core.HashMap/EMPTY bound to m. With 100000 iterations, PersistentHashMap takes 11.8s, whereas HashMap takes forever.

TODO:

  • iron out any remaining bugs, add in missing protocols (if any) etc.,

  • test HashCollisionNode and related code,

  • use other map types for small maps and switch at some threshold.

See https://groups.google.com/d/topic/clojure-dev/DMcV4QwApuY/discussion.

Environment

None

Status

Assignee

Unassigned

Reporter

Michał Marczyk

Labels

None

Approval

None

Patch

Code

Priority

Major