[phobos] I think we need to make an emergency release

Andrei Alexandrescu andrei at erdani.com
Wed Aug 25 13:44:03 PDT 2010


On 8/25/10 6:50 PDT, Steve Schveighoffer wrote:
> OK, looked at it for a while, I wasn't clear originally on what Appender is
> exactly supposed to do.

The idea is to provide a reference type that efficiently appends to an 
array. Previously Appended had two fields (a pointer to the array and 
the capacity) so it wasn't a reference type. This made it impossible to 
pass Appender objects by value and have it work properly.

> I'd recommend scrapping Appender as written and creating one that does the
> following:
>
> 1. if initialized with an existing array, initialize capacity to 0, forcing a
> realloc on first append
> 2. Store the capacity outside the array data (i.e. in a heap-allocated
> array+capacity struct).
>
> Yes, 1 can be inefficient but it errs on the side of safety.  Once it
> reallocates the first time, it will be very efficient.  This works as long as
> the assumption is that you use Appender to append large amounts of data.
>
> I'll work on a proposed replacement Appender struct, it shouldn't take too long.

Great, I'm seeing your other email now.


Andrei


More information about the phobos mailing list