The current implementation of TypeInfo.opEquals is very naive. It calls TypeInfo.toString on both operands and compares the resulting strings. The main problem is that this allocates memory for each comparison.
Another issue is that it may result in false positive comparisons, e.g. when comparing .classinfo of a class and it's updated version.
related:
https://github.com/D-Programming-Language/druntime/pull/370https://github.com/D-Programming-Language/druntime/pull/438
Comment #1 by code — 2013-05-09T22:17:08Z
> Another issue is that it may result in false positive comparisons, e.g. when
> comparing .classinfo of a class and it's updated version.
Why is this a false positive? Thats exactly the behavior you want when reloading changed classes at runtime. You want the new reloaded class to take the place of the old one without anything breaking.
Comment #2 by code — 2013-05-10T07:20:04Z
(In reply to comment #1)
> Why is this a false positive? Thats exactly the behavior you want when
> reloading changed classes at runtime. You want the new reloaded class to take
> the place of the old one without anything breaking.
Because the classinfos might have different vtables and initializers, therefor they should not compare equal. This becomes crucial if you have to deal with both types at the same time.
If you want to hotswap an instance you have to serialize and reinstantiate it.
Comment #3 by robert.schadek — 2024-12-07T13:32:39Z