how to determine a runtime type faster?
davidl
davidl at 126.com
Thu May 10 07:37:56 PDT 2007
great ur way does work
>
>
> 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
>
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list