summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-12-16 16:14:06 +0000
committerDavid Mitchell <davem@iabyn.com>2010-12-16 16:16:14 +0000
commit93d7320bf7eac5942274854396d4ccc6268106c7 (patch)
tree279988fd2159c2ea009a71d79d668d18a1f43228
parent2cf724d498600d69eef0cc9013134e35fd9eff6d (diff)
downloadperl-93d7320bf7eac5942274854396d4ccc6268106c7.tar.gz
only call amagic_deref_call() if we have to
-rw-r--r--pp.c13
-rw-r--r--pp_hot.c13
-rw-r--r--sv.c3
3 files changed, 18 insertions, 11 deletions
diff --git a/pp.c b/pp.c
index b5e93a2f6a..112f4f5f95 100644
--- a/pp.c
+++ b/pp.c
@@ -142,9 +142,10 @@ PP(pp_rv2gv)
if (!isGV(sv) || SvFAKE(sv)) SvGETMAGIC(sv);
if (SvROK(sv)) {
wasref:
- sv = amagic_deref_call(sv, to_gv_amg);
- SPAGAIN;
-
+ if (SvAMAGIC(sv)) {
+ sv = amagic_deref_call(sv, to_gv_amg);
+ SPAGAIN;
+ }
sv = SvRV(sv);
if (SvTYPE(sv) == SVt_PVIO) {
GV * const gv = MUTABLE_GV(sv_newmortal());
@@ -284,8 +285,10 @@ PP(pp_rv2sv)
if (!(PL_op->op_private & OPpDEREFed))
SvGETMAGIC(sv);
if (SvROK(sv)) {
- sv = amagic_deref_call(sv, to_sv_amg);
- SPAGAIN;
+ if (SvAMAGIC(sv)) {
+ sv = amagic_deref_call(sv, to_sv_amg);
+ SPAGAIN;
+ }
sv = SvRV(sv);
switch (SvTYPE(sv)) {
diff --git a/pp_hot.c b/pp_hot.c
index c1d01035a6..9bc7eaeed1 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -827,9 +827,10 @@ PP(pp_rv2av)
if (!(PL_op->op_private & OPpDEREFed))
SvGETMAGIC(sv);
if (SvROK(sv)) {
- sv = amagic_deref_call(sv, is_pp_rv2av ? to_av_amg : to_hv_amg);
- SPAGAIN;
-
+ if (SvAMAGIC(sv)) {
+ sv = amagic_deref_call(sv, is_pp_rv2av ? to_av_amg : to_hv_amg);
+ SPAGAIN;
+ }
sv = SvRV(sv);
if (SvTYPE(sv) != type)
DIE(aTHX_ "Not %s reference", is_pp_rv2av ? an_array : a_hash);
@@ -2794,8 +2795,10 @@ PP(pp_entersub)
}
SvGETMAGIC(sv);
if (SvROK(sv)) {
- sv = amagic_deref_call(sv, to_cv_amg);
- /* Don't SPAGAIN here. */
+ if (SvAMAGIC(sv)) {
+ sv = amagic_deref_call(sv, to_cv_amg);
+ /* Don't SPAGAIN here. */
+ }
}
else {
const char *sym;
diff --git a/sv.c b/sv.c
index 2cabf7be06..4371375afc 100644
--- a/sv.c
+++ b/sv.c
@@ -8812,7 +8812,8 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref)
default:
if (SvROK(sv)) {
SvGETMAGIC(sv);
- sv = amagic_deref_call(sv, to_cv_amg);
+ if (SvAMAGIC(sv))
+ sv = amagic_deref_call(sv, to_cv_amg);
/* At this point I'd like to do SPAGAIN, but really I need to
force it upon my callers. Hmmm. This is a mess... */