This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Something like vector-grow available?


> is there an easy way to grow a vector dynamically?  At the moment I
> allocate a new one and copy all elements to this new vector.
> 
> Is there a more elegant solution?

Just use:

	(set! (vector-length v) 50)

Oh, hang on, I keep thinking that we have already caught up with perl.

AFAIK, no there is not. The implementation of a vector is a simple malloc()
and the chances for a realloc() on that working without doing a copy are
pretty small. The copy inside realloc() is faster than anything you write
in scheme though. Adding a vector-grow function to guile might be nice for
just that reason and possibly for the reason that some future implementation
might be smarter.

	- Tel

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]