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

Optimize transient vector creation

Description

This is a very simple optimization around transient []. It avoids copying the empty array.

Performance improvements, for mapv on smallish vectors (5-32) elements anywhere from 20% up to 100% across FF & Chrome.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 (defn faster-editable-root [node] (if (identical? (.-EMPTY_NODE PersistentVector) node) (VectorNode. (js-obj) (make-array 32)) (VectorNode. (js-obj) (aclone (.-arr node))))) (def orig-editabe-root tv-editable-root) (enable-console-print!) (dotimes [_ 2] (doseq [size [5 10 40]] (let [xs (range size) sims 500000] (set! tv-editable-root orig-editabe-root) (prn "Size: " size) (simple-benchmark [] (mapv inc xs) sims) (set! tv-editable-root faster-editable-root) (prn "NEW:") (simple-benchmark [] (mapv inc xs) sims))))

Environment

None

Status

Assignee

David Nolen

Reporter

Andre R

Labels

Approval

None

Patch

Code

Affects versions

1.9.655

Priority

Minor