Cost of assoc array?

dennis luehring via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 14 03:54:56 PDT 2014


Am 14.05.2014 12:33, schrieb Chris:
> On Wednesday, 14 May 2014 at 10:20:51 UTC, bearophile wrote:
>> Chris:
>>
>>> Is there any huge difference as regards performance and memory
>>> footprint between the two? Or is 2. basically 1. under the
>>> hood?
>>
>> An associative array is a rather more complex data structure,
>> so if you don't need it, use something simpler. There is
>> difference in both the amount of memory used and performance
>> (in many cases such difference doesn't matter). In D there are
>> also differences in the way they are initialized from a null or
>> fat null.
>>
>> Bye,
>> bearophile
>
> Thanks. Do you mean the difference is negligible in many cases?
> I'm not sure, because changing it would be a breaking change in
> the old code, meaning I would have to change various methods.

a simple array would be faster because no access is generate for your 
key - just plain access, just don't use assoc arrays if you don't need 
key based access

read more manuals about hashmaps and stuff and how to do benchmarking - 
helps alot in the future




More information about the Digitalmars-d-learn mailing list