Reserving capacity in associative arrays

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 16 09:05:11 PST 2016


On Tuesday, 16 February 2016 at 16:37:07 UTC, Steven 
Schveighoffer wrote:
> There is not a public way to access these methods unfortunately.
>
> It would be a good addition to druntime I believe.
>
> Recently, I added a clear method to the AA, which does not 
> reduce capacity. So if you frequently build large AAs, and then 
> throw them away, you could instead reuse the memory.
>
> I would caution to be sure of this cause, however, before 
> thinking it would solve the problem. The AA not only uses an 
> array for buckets, but allocates a memory location for each 
> element as well. I'm often wrong when I assume what the problem 
> is when it comes to GC issues...
>
> -Steve

After reading the topic i've added this enhancement proposal, not 
quite sure if it's possible:

https://issues.dlang.org/show_bug.cgi?id=15682

The idea is to concatenate smallers AA into the destination.


More information about the Digitalmars-d-learn mailing list