www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Classinfo and nogc conflict

reply solidstate1991 <laszloszeremi outlook.com> writes:
I'm trying to speed up my graphic engine, however the presence of 
the GC in function Layer.updateRaster (see here: 
https://github.com/ZILtoid1991/pixelperfectengine/blob/master/pixelperfectengine/src/PixelPerfectEngi
e/graphics/layers.d ) means I get an occasional bump in CPU usage if not a
framedrop (most performance related thing got fixed since then).

I use classinfo for detecting the type of bitmaps, and while I 
probably will have a workaround for the associative array stuff, 
the classinfo thing is embedded into the runtime library, thus it 
needs to be fixed. I took a look at opEquals, but the trickier 
part would be making the toString function  nogc (make its return 
value a ref type?).
Mar 05 2018
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 6 March 2018 at 03:07:49 UTC, solidstate1991 wrote:
 I use classinfo for detecting the type of bitmaps, and while I 
 probably will have a workaround for the associative array stuff
Have you tried `item.classinfo is typeid(xxx)` so `is` instead of `==`? That... might not work across shared libraries, but otherwise it should give the same comparison without any string compare.
 but the trickier part would be making the toString function 
  nogc (make its return value a ref type?).
There's already options for toString((char[] s) { process s here } ) that can dump it into a stack buffer. Perhaps the druntime function could call that overload instead of the zero-arg version too.
Mar 06 2018