Is the memory address of classinfo the same for all instances of a class?

Simen kjaeraas simen.kjaras at gmail.com
Fri Jul 2 11:29:08 PDT 2010


Heywood Floyd <soul8o8 at gmail.com> wrote:

> I noted that the classinfo.name-strings typically looks like this:
>
> 	classtype.Foo
> 	classtype.Bar
> 	classtype.Cat
> 	classtype.Dog
>
> Doesn't this first "classtype."-part introduce overhead when these  
> strings are used as keys in an AA? The string comparer more or less  
> always have to check the first 10 chars, which are equal for all. (I  
> know I'm being picky here. But the whole using memory addresses-thing  
> came from the fear of string comparisons being suboptimal.)

Have you profiled your code and found that comparing classinfo is a
bottleneck? If it is, have you considered a two-layer system? i.e.
foo[transmutedClassInfo], where transmutedClassInfo is the result of
another lookup, that is based purely on the pointer to the classInfo?

> (PS. Feature-request: move the "classtype."-part of classinfo names to  
> the end ; )

I find it unlikely that will ever happen. The classinfo name should be
the same as the FQN of the class.

-- 
Simen


More information about the Digitalmars-d-learn mailing list