PersistentArrayMap.fromArray
function | since v0.0-1798 | Edit |
(PersistentArrayMap.fromArray arr no-clone no-check)
(set! (.-fromArray PersistentArrayMap)
(fn [arr ^boolean no-clone ^boolean no-check]
(as-> (if no-clone arr (aclone arr)) arr
(if no-check
arr
(let [ret (array)]
(loop [i 0]
(when (< i (alength arr))
(let [k (aget arr i)
v (aget arr (inc i))
idx (array-index-of ret k)]
(when (== idx -1)
(.push ret k)
(.push ret v)))
(recur (+ i 2))))
ret))
(let [cnt (/ (alength arr) 2)]
(PersistentArrayMap. nil cnt arr nil)))))