X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=universal.c;h=24aa3b8e489eeb366460342b3db733ed952c0dee;hb=b70307b60b7dcc706d4c6a9deaa669f6a0a9a0d9;hp=097cc64e0785073193355f8d0098ce5b3f0e75f4;hpb=c445ea15829fa1ef23c4453a817f9c096a56a192;p=p5sagit%2Fp5-mst-13.2.git diff --git a/universal.c b/universal.c index 097cc64..24aa3b8 100644 --- a/universal.c +++ b/universal.c @@ -140,29 +140,29 @@ for class names as well as for objects. bool Perl_sv_derived_from(pTHX_ SV *sv, const char *name) { - const char *type = NULL; - HV *stash = NULL; - HV *name_stash; + HV *stash; SvGETMAGIC(sv); if (SvROK(sv)) { + const char *type; sv = SvRV(sv); type = sv_reftype(sv,0); - if (SvOBJECT(sv)) - stash = SvSTASH(sv); + if (type && strEQ(type,name)) + return TRUE; + stash = SvOBJECT(sv) ? SvSTASH(sv) : NULL; } else { stash = gv_stashsv(sv, FALSE); } - name_stash = gv_stashpv(name, FALSE); + if (stash) { + HV * const name_stash = gv_stashpv(name, FALSE); + return isa_lookup(stash, name, name_stash, strlen(name), 0) == &PL_sv_yes; + } + else + return FALSE; - return (type && strEQ(type,name)) || - (stash && isa_lookup(stash, name, name_stash, strlen(name), 0) - == &PL_sv_yes) - ? TRUE - : FALSE ; } #include "XSUB.h"