summaryrefslogtreecommitdiff
path: root/pp.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-11-03 14:57:11 +0000
committerNicholas Clark <nick@ccl4.org>2010-11-03 15:04:34 +0000
commit25a9ffce153b0e67cfefd260754edeb097da5be7 (patch)
tree6d7e60d1842fa73c3f0fcec7cc9a2e2272baf085 /pp.h
parent7d255dc8b56bf0fe58c3f8a5aa84ba17aade145f (diff)
downloadperl-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.h17
1 files changed, 2 insertions, 15 deletions
diff --git a/pp.h b/pp.h
index 27f948cfdc..3f2aea9dca 100644
--- a/pp.h
+++ b/pp.h
@@ -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))