PersistentHashSet.fromArray

functionsince v0.0-1443Edit
(PersistentHashSet.fromArray items no-clone)

Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(set! (.-fromArray PersistentHashSet)
  (fn [items ^boolean no-clone]
    (let [len (alength items)]
      (if (<= len (.-HASHMAP-THRESHOLD PersistentArrayMap))
        (let [arr (if no-clone items (aclone items))]
          (loop [i 0
                 out (transient (.-EMPTY PersistentArrayMap))]
            (if (< i len)
              (recur (inc i) (-assoc! out (aget items i) nil))
              (PersistentHashSet. nil (-persistent! out) nil))))
       (loop [i 0
              out (transient (.-EMPTY PersistentHashSet))]
         (if (< i len)
           (recur (inc i) (-conj! out (aget items i)))
           (-persistent! out)))))))