guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Growable arrays?


From: David Kastrup
Subject: Re: Growable arrays?
Date: Mon, 11 Jun 2012 12:38:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Daniel Hartwig <address@hidden> writes:

> On 11 June 2012 17:01, Daniel Hartwig <address@hidden> wrote:
>> For reference, attached is a growable vector I use in several
>> projects, adapted to support the length operation similar to Lua (i.e.
>> first unset numerical index).  There is no catching of exceptions
>> here, every access to the data is through the dynvector procedures
>> which check the index and vector size.
>
> Always test before posting even small changes to existing code :-)
>
> Updated attachment to actually run without problems

Well, considering the cost of dynvector-grow!, doing the growth in a
loop rather then just the determination of the new size seems a bit
expensive:

  (while (<= (dynvector-capacity dynvector) k)
    (dynvector-grow! dynvector))

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]