Commits

Anonymous committed c2a3c3f

we don't have no arrays around here

Comments (0)

Files changed (1)

clojurian-vector.scm

 ;; (deftype VectorNode [edit arr])
 
 (define-record pv-node
-  edit arr)
+  edit vec)
 
 ;; deftype PersistentVector [meta cnt shift root tail ^:mutable __hash]
 (define-record pv
 ;;   (aget (.-arr node) idx))
 
 (define (pv-aget node idx)
-  (vector-ref (pv-node-arr node) idx))
+  (vector-ref (pv-node-vec node) idx))
 
 ;; (defn- pv-aset [node idx val]
 ;;   (aset (.-arr node) idx val))
 
 (define (pv-aset node idx val)
-  (vector-set! (pv-node-arr node) idx val))
+  (vector-set! (pv-node-vec node) idx val))
 
 ;; (defn- pv-clone-node [node]
 ;;   (VectorNode. (.-edit node) (aclone (.-arr node))))
 (define (pv-clone-node node)
   (make-pv-node (pv-node-edit node)
-                    (vector-copy (pv-node-arr node))))
+                    (vector-copy (pv-node-vec node))))
 
 
 ;; (defn- tail-off [pv]
 ;;     (throw (js/Error. (str "No item " i " in vector of length " (.-cnt pv))))))
 
 
-(define (array-for pv i)
+(define (vector-for pv i)
   (if (and (<= 0 i) (< i (pv-cnt pv)))
       (if (>= i (tail-off pv))
           (pv-tail pv)
                 (loop (pv-aget node (-> (arithmetic-shift-right/zero-fill i level)
                                         (bitwise-and #x01f)))
                       (- level 5))
-                (pv-node-arr node))))
+                (pv-node-vec node))))
       (error "Vector index out of bounds" i (pv-cnt pv))))
 
 
                (pv-root pv)
                (vector-copy (pv-tail pv) -2)))
      (else
-      (let* ((new-tail (array-for pv (- cnt 2)))
+      (let* ((new-tail (vector-for pv (- cnt 2)))
              (nr (pop-tail pv (pv-shift pv) (pv-root pv)))
              (new-root (or nr +empty-vector+))
              (cnt-1 (- cnt 1)))
 (define pv-ref
   (case-lambda
    ((pv n)
-    (vector-ref (array-for pv n) (bitwise-and n #x01f)))
+    (vector-ref (vector-for pv n) (bitwise-and n #x01f)))
    ((pv n not-found)
     (if (and (<= 0 n) (< n (pv-cnt pv)))
         (pv-ref pv n)