diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-11-03 14:57:11 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-11-03 15:04:34 +0000 |
commit | 25a9ffce153b0e67cfefd260754edeb097da5be7 (patch) | |
tree | 6d7e60d1842fa73c3f0fcec7cc9a2e2272baf085 /pp.h | |
parent | 7d255dc8b56bf0fe58c3f8a5aa84ba17aade145f (diff) | |
download | perl-25a9ffce153b0e67cfefd260754edeb097da5be7.tar.gz |
Add Perl_amagic_deref_call() to implement the bulk of tryAMAGICunDEREF_var().
This removes around 300 bytes of object code from each place it was previously
inlined. It also provides a better interface - quite a lot of the core
currently bodges things by creating a local variable C<SV **sp = &sv> to use
the macro.
Change the XS::APItest wrapper to amagic_deref_call().
Diffstat (limited to 'pp.h')
-rw-r--r-- | pp.h | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -451,21 +451,8 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>. #define tryAMAGICunDEREF_var(meth_enum) \ STMT_START { \ - SV *tmpsv; \ - SV *arg = *sp; \ - while (SvAMAGIC(arg) && \ - (tmpsv = amagic_call(arg, &PL_sv_undef, meth_enum, \ - AMGf_noright | AMGf_unary))) { \ - SPAGAIN; \ - sv = tmpsv; \ - if (!SvROK(tmpsv)) \ - Perl_croak(aTHX_ "Overloaded dereference did not return a reference"); \ - if (tmpsv == arg || SvRV(tmpsv) == SvRV(arg)) { \ - /* Bail out if it returns us the same reference. */ \ - break; \ - } \ - arg = tmpsv; \ - } \ + sv = amagic_deref_call(aTHX_ *sp, meth_enum); \ + SPAGAIN; \ } STMT_END #define tryAMAGICunDEREF(meth) tryAMAGICunDEREF_var(CAT2(meth,_amg)) |