On Thu, May 22, 2014 at 10:49:39AM +0100, Tim Bunce wrote: > On Wed, May 21, 2014 at 11:00:57AM +0100, Nicholas Clark wrote: > > Attached are two patches that remove use of dTHX in functions in quote.c > > and types.c > > > > dTHX is ithreads only, but relatively expensive, as it needs to make a > > function call to retreive a value from thread local storage. It's much > > better to pass that value as a function parameter, as the caller will have > > it already. > > Thanks Nicholas! > > > I can't see how to make the same change to dbdimp.c without also changing > > Driver.xst to optionaly support it. > > That would be tricky. > > The handle data structure includes the PerlInterpreter* of the thread > that created it https://github.com/perl5-dbi/dbi/blob/master/DBIXS.h#L95 > > and the DBI's method dispatcher ensures that DBI methods are only called > in the same thread that created them, i.e. > > https://github.com/perl5-dbi/dbi/blob/master/DBI.xs#L3300 > > So, for methods that are passed a handle and already declare and set a > local imp_xxh pointer (e.g., D_imp_sth(sth);) I wonder if it would be > worth defining a macros to get the thread pointer from the handle. > Something like dTHX_from_imp_xxh(imp_xxh);
I don't think that this will work #define D_imp_sth(h) D_impdata(imp_sth, imp_sth_t, h) #define D_impdata(name,type,h) type *name = (type*)(DBIh_COM(h) #ifdef IN_DBI_XS /* get Handle Common Data Structure */ #define DBIh_COM(h) (dbih_getcom2(aTHX_ h, 0)) #else #define DBIh_COM(h) (DBIS->getcom(h)) #define neatsvpv(sv,len) (DBIS->neat_svpv(sv,len)) #endif You need a copy of my_perl (that aTHX_) to get the to data structure that contains my_perl (if I follow the macros correctly) Nicholas Clark
