Details
-
Type:
Enhancement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Patch:Code
Description
The attached patch (to be applied on top of the CLJS-189 patch – otherwise tests don't pass, and for good reason) removes the deprecation notice on ObjMap and reintroduces the code for emitting ObjMaps in the compiler as per yesterday's discussion on #clojure (see http://clojure-log.n01se.net/date/2012-04-20.html#18:58a).
With this patch applied, ObjMaps will be automagically converted to PersistentHashMaps once a they grow beyond 16 entries. The compiler will also only omit ObjMap creation code for small maps (up to 16 entries).
ObjMap is meant to provide native-JS-object-level access speed in ClojureScript, particularly for literal maps with literal simple keys. The behaviour of the latter kind of maps was not tested at all in the jsPerf test suite on the PHM patch; links to new tests with literals forthcoming.
New patch against current master.
Here's a jsPerf test:
http://jsperf.com/cljs-literal-maps-4
ObjMap does indeed win on access time, but incredibly the ObjMap created from a literal seems slower than the one created by associng the keys onto cljs.core.ObjMap/EMPTY. I'll think about possible sources of systematic error.
The prep code was generated using https://github.com/michalmarczyk/cljs-persistent-hash-map-test (current commit sha: 0812c5cd76d78060605829e3e78eb3d841fa3238).