Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: 1.9.655
    • Fix versions: None
    • Labels:
    • Patch:
      Code

      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.

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

        Attachments

          Activity

            People

            • Assignee:
              dnolen David Nolen
              Reporter:
              aralo Andre R
            • Votes:
              3 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: