Thread overview
[Issue 10048] New: TypeInfo comparison allocates memory
May 08, 2013
Martin Nowak
May 10, 2013
Benjamin Thaut
May 10, 2013
Martin Nowak
May 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10048

           Summary: TypeInfo comparison allocates memory
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@dawg.eu


--- Comment #0 from Martin Nowak <code@dawg.eu> 2013-05-08 11:09:49 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10048


Benjamin Thaut <code@benjamin-thaut.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@benjamin-thaut.de


--- Comment #1 from Benjamin Thaut <code@benjamin-thaut.de> 2013-05-09 22:17:08 PDT ---
> 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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10048



--- Comment #2 from Martin Nowak <code@dawg.eu> 2013-05-10 07:20:04 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------