ClojureScript

Details

Type:
Enhancement

Status:
Closed

Priority:
Major

Resolution:
Completed

Affects Version/s:1.9.908

Fix Version/s:
None

Component/s:
None

Labels:

None

Patch:

Code

Approval:

Accepted

Description

js-keys is implemented using goog.object/forEach. This essentially results in JavaScript that does a for over each key in the object, (just like goog.object/getKeys), but instead of directly accumulating the keys in a JavaScript array, using forEach ends up incurring unnecessary overhead extracting (and ultimately discarding) the value associated with each key, and making a callback for each key. In :none mode, you can see that goog.object/getKeys can be twice as fast as js-keys at times (at least in JavaScriptCore—work for this ticket should probably include a new benchmark.)

This ticket asks that js-keys be implemented by directly delegating to good.object/getKeys. There are a few places, in printing, and in js->clj that could benefit from this speedup (and with the simple delegation, good.object/getKeys could even be inlined by hand at call sites if it improved perf).