Associative array of strings perf

Martin Nowak dawg at dawgfoto.de
Sat Nov 19 12:33:57 PST 2011


On Sat, 19 Nov 2011 04:07:51 +0100, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Do you know why an associative array like this:
> uint[immutable(char)[]] aa;
>
> Is almost two times faster than a very similar associative array like  
> this?
> uint[immutable(E)[]] aa;
>
> Where E is a named typed enum of chars like:
> enum E : char { a='a', b='b', c='c', d='d', ... }
>
> Testing code:
> http://codepad.org/hzcRH8Bd
>
> Bye,
> bearophile

take a look at

     writeln(typeid(immutable(char)[]).classinfo.name); // TypeInfo_Aya  
 from rt.typeinfo.ti_Ag
     writeln(typeid(immutable(E)[]).classinfo.name);    // TypeInfo_Array  
 from object.d

The string typeinfos use a cheaper hash algorithm.


More information about the Digitalmars-d mailing list