From: Yuval Kogman Date: Thu, 21 Aug 2008 11:16:55 +0000 (+0000) Subject: trigger SvGETMAGIC in check_sv_type X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8a73f7967360f242c87635c01bc5c009d82accfc;p=gitmo%2FMoose.git trigger SvGETMAGIC in check_sv_type --- diff --git a/Moose.xs b/Moose.xs index 5f6e37c..685f565 100644 --- a/Moose.xs +++ b/Moose.xs @@ -408,6 +408,8 @@ STATIC bool check_sv_type (TC type, SV *sv) { if (!sv) return 0; + SvGETMAGIC(sv); + switch (type) { case Any: return 1; @@ -466,10 +468,14 @@ STATIC bool check_sv_type (TC type, SV *sv) { break; case RegexpRef: case Object: - if ( sv_isobject(sv) ) { - char *name = HvNAME_get(SvSTASH(SvRV(sv))); - bool is_regexp = strEQ("Regexp", name); - return ( (type == RegexpRef) ^ !is_regexp ); + /* not using sv_isobject to avoid repeated get magic */ + if ( SvROK(sv) ) { + SV *rv = SvRV(sv); + if ( SvOBJECT(rv) ) { + char *name = HvNAME_get(SvSTASH(SvRV(sv))); + bool is_regexp = strEQ("Regexp", name); + return ( (type == RegexpRef) ^ !is_regexp ); + } } return 0; break;