The demise of T[new]

Denis Koroskin 2korden at gmail.com
Tue Oct 20 10:14:36 PDT 2009


On Tue, 20 Oct 2009 21:01:17 +0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> grauzone wrote:
>> Steven Schveighoffer wrote:
>>> I still think having an Appender object or struct is a worthwhile  
>>> thing, the "pre-allocate array then set length to zero" model is a  
>>> hack at best.
>>  Would that work with Andrei's append cache at all? Setting the length  
>> to zero and then appending is like taking a slice of length 0 and then  
>> appending.
>>  Maybe introduce a write/readable .capacity property, that magically  
>> accesses the cache/GC?
>
> For my money, I'd get rid of that trick:
>
> a.length = 1000;
> a.length = 0;
> for (...) a ~= x;
>
>
> Andrei

I agree it's ugly but that's the best we have in D, and it looks like  
things are getting even worse...



More information about the Digitalmars-d mailing list