About built-in AAs

kennytm kennytm at gmail.com
Tue Aug 16 20:31:17 PDT 2011


bearophile <bearophileHUGS at lycos.com> wrote:
> 
> Now and then I compare the running time of C++0x code that uses
> <unordered_map> with the running time of the same operations done with D
> AAs and I don't see good timings for D. Are D AAs true templates or do
> they use some runtime typeid function? If they aren't true templates
> isn't it better to change this?
> 
> Bye,
> bearophile

They use runtime typeid functions. Some V[K] type and methods are converted
to AssociativeArray!(K, V) which itself is a proxy to those extern(C)
aaGetX() functions. Some methods will resolve to those aaGetX directly in
DMD. These functions can only know what types they're working on via the
typeid.  

IMO in DMD V[K]'s methods shouldn't be special. They should be treated just
as a syntactic substitution for the AssociativeArray!(K, V) type. The
latter shall implement opIndex etc for its normal operation. Druntime gets
to decide whether to continue using the C interface or turn it into a
concrete templated structure.  This also solves bug 5350.


More information about the Digitalmars-d mailing list