Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
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.


(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))))

4 Answers

0 votes
by

Comment made by: mfikes

CLJS-2132.patch passes CI (/)

0 votes
by

Comment made by: mfikes

CLJS-2132.patch added to Patch Tender (i)

0 votes
by

Comment made by: mfikes

CLJS-2132.patch passes Canary (/)

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2132 (reported by aralo)
Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.
...