From ce449ab9e8048fefc01f90e23074cf281c42d3a4 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Fri, 30 Nov 2012 11:56:28 +0100 Subject: [PATCH] copy-subarray is now inlined and used in arraylib.lsp --- src/cmp/sysfun.lsp | 4 ++++ src/lsp/arraylib.lsp | 23 +++-------------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/cmp/sysfun.lsp b/src/cmp/sysfun.lsp index 0adcea93f..df81dbdac 100644 --- a/src/cmp/sysfun.lsp +++ b/src/cmp/sysfun.lsp @@ -190,6 +190,10 @@ (def-inline si:row-major-aset :unsafe ((array fixnum) fixnum fixnum) :fixnum "(#0)->array.self.fix[#1]= #2") +(def-inline si:copy-subarray :always (array ext:array-index array ext:array-index + ext:array-index) array + "@0;(ecl_copy_subarray(#0,#1,#2,#3,#4),#0)") + (def-inline array-rank :unsafe (array) :fixnum "@0;(((#0)->d.t == t_array)?(#0)->array.rank:1)") (def-inline array-rank :always (array) :fixnum diff --git a/src/lsp/arraylib.lsp b/src/lsp/arraylib.lsp index 8d4807aae..1e65f595b 100644 --- a/src/lsp/arraylib.lsp +++ b/src/lsp/arraylib.lsp @@ -299,18 +299,7 @@ pointer is 0 already." (i2 start2)) (declare (ext:array-index d1 d2 l i1 i2)) (if (null dims1) - #+ecl-min - (dotimes (i l) - (declare (ext:array-index i)) - (row-major-aset dest i1 (row-major-aref orig i2)) - (incf i1) - (incf i2)) - #-ecl-min - (ffi::c-inline (dest i1 orig i2 l) - (array :fixnum array :fixnum :fixnum) :void - "ecl_copy_subarray(#0, #1, #2, #3, #4)" - :one-liner t - :side-effects t) + (copy-subarray dest i1 orig i2 l) (let ((step1 (apply #'* dims1)) (step2 (apply #'* dims2))) (declare (ext:array-index step1 step2)) @@ -366,14 +355,8 @@ adjustable array." (cond ((adjustable-array-p vec) (adjust-array vec len)) ((typep vec 'simple-array) - (let ((new-vec (make-array len :element-type - (array-element-type vec)))) - (check-type len fixnum) - (locally (declare (optimize (speed 3) (safety 0) (space 0)) ) - (dotimes (i len) - (declare (fixnum i)) - (setf (aref new-vec i) (aref vec i)))) - new-vec)) + (let ((new-vec (make-array len :element-type (array-element-type vec)))) + (copy-subarray new-vec 0 vec 0 len))) ((typep vec 'vector) (setf (fill-pointer vec) len) vec)