X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcode%2Farray.lisp;h=b1239ca8a2e56ea4663a94b148bd4246fc24be6d;hb=f23ae013c574b6b2fef2230a95f5688050b17689;hp=7c2790ea48818db6fc31b17d4eb3c6f7458ad8b0;hpb=5758a6ab4c2d046b68b5409d13ed6b8d6199ba7c;p=sbcl.git diff --git a/src/code/array.lisp b/src/code/array.lisp index 7c2790e..b1239ca 100644 --- a/src/code/array.lisp +++ b/src/code/array.lisp @@ -1083,6 +1083,31 @@ of specialized arrays is supported." (setf (%array-dimension array 0) dimensions)) (setf (%array-displaced-p array) displacedp) array) + +;;; User visible extension +(declaim (ftype (function (simple-array) (values (simple-array * (*)) &optional)) + simple-array-vector)) +(defun simple-array-vector (array) + "Returns the one-dimensional SIMPLE-ARRAY corresponding to ARRAY. + +The ARRAY must be a SIMPLE-ARRAY. If ARRAY is multidimensional, returns the +underlying one-dimensional SIMPLE-ARRAY which shares storage with ARRAY. +Otherwise returns ARRAY. + +Currently in SBCL a multidimensional SIMPLE-ARRAY has an underlying +one-dimensional SIMPLE-ARRAY, which holds the data in row major order. This +function provides access to that vector. + +Important note: the underlying vector is an implementation detail. Even though +this function exposes it, changes in the implementation may cause this +function to be removed without further warning." + ;; KLUDGE: Without TRULY-THE the system is not smart enough to figure out that + ;; (1) SIMPLE-ARRAY without ARRAY-HEADER-P is a vector (2) the data vector of + ;; a SIMPLE-ARRAY is a vector. + (truly-the (simple-array * (*)) + (if (array-header-p array) + (%array-data-vector array) + array))) ;;;; used by SORT