Christophe Rhodes <[EMAIL PROTECTED]> writes:

> On Thu, Sep 12, 2002 at 11:35:22AM +0200, Edi Weitz wrote:
> > 2. Also, the speed gains are lost if X is fixed, i.e. 
> 
> I think this is the key.
> 
> In
>   (defun foo (x)
>     (make-array x :initial-element 0))
> x can be a FIXNUM (skating over some complications arising from
> implementation-dependent limits) or a list of FIXNUMs; for instance,
> the call (FOO '(1 2)) is perfectly valid, and will return a
> two-dimensionaly array.
> 
> If you will always be making vectors, then either declaring X to be
> of type FIXNUM or using MAKE-SEQUENCE with a constant sequence type
> (of (VECTOR T), in this case) should give you the speedup you want.

Yes, that was it. Declaring the array dimensions specifier to be
FIXNUM makes my program as fast as with the funny COPY-SEQ
trick. Somehow it didn't occur to me that arrays can have more than
one dimension... :(

Thanks, I'm relieved that I now have a version that is fast on CMUCL
but also nice to non-CMUCL-Lisps (without the need to have #+CMU/#-CMU
stuff in there).

Sorry for the noise,
Edi.

PS: The arrays are always one-dimensional, rather short (most of them
    have fewer than 10 elements), and their elements are of type
    FIXNUM or (OR FIXNUM NULL). Should I prefer MAKE-ARRAY or
    MAKE-SEQUENCE?

Reply via email to