how to determine a runtime type faster?
Daniel Keep
daniel.keep.lists at gmail.com
Thu May 10 06:47:38 PDT 2007
davidl wrote:
> module funky.super.meaningless.modulename;
> class base
> {
> }
> class derive:base
> {
> }
> void main()
> {
> derive instance= new derive;
> base castedinstance=instance;
> // notice the following would result a super long string comparision
> , which is not so good.
> //
> `funky.super.meaningless.modulename.derive`==`funky.super.meaningless.modulename.derive`
>
> assert(castedinstance.classinfo.name==derive.classinfo.name);
>
> }
> the idea is castedinstance.classinfo.runtimeid?
> the runtimeid could generated by the compiler and with some proper
> design about object.d , i think
> the comparision could be faster
Have you tried comparing the classinfo directly? I have a feeling they
should be the same for every instance of a particular class...
-- Daniel
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
http://xkcd.com/
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d
mailing list