             (.copy-and-set-node inode aedit bit sub-node-new)
             inode))
         :else
-        (let [n (bit-count datamap)
-              idx (bitmap-indexed-node-index datamap bit)
-              new-arr (make-array (* 2 (inc n)))]
-          (array-copy arr 0 new-arr 0 (* 2 idx))
-          (aset new-arr (* 2 idx) key)
-          (aset new-arr (inc (* 2 idx)) val)
-          (array-copy arr (* 2 idx) new-arr (* 2 (inc idx)) (* 2 (- n idx)))
+        (let [n (alength arr)
+              idx (* 2 (bitmap-indexed-node-index datamap bit))
+              new-arr (make-array (+ 2 n))]
+          (array-copy arr 0 new-arr 0 idx )
+          (aset new-arr idx key)
+          (aset new-arr (inc idx) val)
+          (array-copy arr idx new-arr (+ 2 idx) (- n idx))
           (set! (.-added changed?) true)
           (BitmapIndexedNode. aedit (bit-or datamap bit) nodemap new-arr)))))
 

        (.inode-lookup (node-at arr nodemap bit) (+ shift 5) hash key not-found)
        :else
        not-found)))
  (inode-find [inode shift hash key not-found]
    (let [bit (bitpos hash shift)]
      (cond

                            create-inode-seq create-array-node-seq create-node
                            mask bitmap-indexed-node-index bitpos]))

(declare NodeSeq HashCollisionNode TransientHashMap PersistentHashMap)

(deftype Box [^:mutable added ^:mutable modified])

