On 18/05/2015 01:47, Marvin Humphrey wrote:
All of this could be simplified by replacing S_lazy_init_host_obj with
sv_bless. It seems that Clownfish had to create the inner Perl objects
without the outer reference at some point, but this doesn't seem to be
necessary anymore.
The motivation for using only the inner object is that the outer object simply
is not needed. Creating it takes some amount of time and keeping it occupies
some amount of memory.
But the only caller of S_lazy_init_host_obj is CFISH_Obj_To_Host_IMP and this
method needs the outer object. Currently, it creates the outer reference via
newRV_inc. It would be easier if S_lazy_init_host_obj returned an incref'd,
blessed reference (`outer_obj`) which could be used directly by
CFISH_Obj_To_Host_IMP:
https://github.com/nwellnhof/lucy-clownfish/commits/sv_bless
The cost of creating and
immediately destroying the RV is presumably worth the benefit in reduced code
complexity.
With the approach outlined above, creating and destroying the RV isn't needed.
Creating Perl objects manually still has some performance benefits, but it
seems like a maintenance nightmare.
Nick