Assigning global and static associative arrays

Jonathan M Davis jmdavisProg at gmx.com
Sat Sep 1 01:17:27 PDT 2012


On Saturday, September 01, 2012 09:39:04 Philippe Sigaud wrote:
> On Sat, Sep 1, 2012 at 12:21 AM, Jonathan M Davis <jmdavisProg at gmx.com> 
wrote:
> > Using an enum is particularly bad for an AA, since it's not exactly a
> > simple data type, and there's definitely some cost to constructing them.
> 
> Yeah, my (nasty) bad. I'm too used to put 'enum' everywhere.
> 
> Gosh, I confirm using static this() instead of enum results in a 40%
> decrease in runtime for me.
> I'll scourge my code from enum AA...

Using enum can be very useful, but I wouldn't use it for AAs at all, and I'd 
be leery of using it for much in the way of arrays other than string literals 
(since the string literals should avoid the memory allocations that other 
array literals get). It's fine most other stuff, but for those items, you need 
to be very wary of it or risk lots of unnecessary GC allocations.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list