factor out ALLOCATE-VECTOR-WITH-WIDETAG function from MAKE-ARRAY
authorNathan Froyd <froydnj@gmail.com>
Thu, 20 Dec 2012 04:27:32 +0000 (23:27 -0500)
committerNathan Froyd <froydnj@gmail.com>
Thu, 20 Dec 2012 04:51:20 +0000 (23:51 -0500)
src/code/array.lisp

index c700d7b..79e7545 100644 (file)
        (bit #.sb!vm:complex-bit-vector-widetag)
        (t #.sb!vm:complex-vector-widetag)))))
 
+(defun allocate-vector-with-widetag (widetag length n-bits)
+  (declare (type (unsigned-byte 8) widetag)
+           (type index length)
+           (type (integer 0 256) n-bits))
+  (allocate-vector widetag length
+                   (ceiling
+                    (* (if (or (= widetag sb!vm:simple-base-string-widetag)
+                               #!+sb-unicode
+                               (= widetag
+                                  sb!vm:simple-character-string-widetag))
+                           (1+ length)
+                           length)
+                       n-bits)
+                    sb!vm:n-word-bits)))
+
 (defun make-array (dimensions &key
                               (element-type t)
                               (initial-element nil initial-element-p)
           (declare (type (unsigned-byte 8) type)
                    (type (integer 0 256) n-bits))
           (let* ((length (car dimensions))
-                 (array (allocate-vector
-                         type
-                         length
-                         (ceiling
-                          (* (if (or (= type sb!vm:simple-base-string-widetag)
-                                     #!+sb-unicode
-                                     (= type
-                                        sb!vm:simple-character-string-widetag))
-                                 (1+ length)
-                                 length)
-                             n-bits)
-                          sb!vm:n-word-bits))))
+                 (array (allocate-vector-with-widetag type length n-bits)))
             (declare (type index length))
             (when initial-element-p
               (fill array initial-element))