Bug 10048 – TypeInfo comparison allocates memory

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-08T11:09:49Z
Last change time
2024-12-07T13:32:39Z
Assigned to
No Owner
Creator
Martin Nowak
Moved to GitHub: dmd#17254 →

Comments

Comment #0 by code — 2013-05-08T11:09:49Z
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/370 https://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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17254 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB