diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-23 18:15:48 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-23 20:06:26 -0700 |
commit | ad6acfc4a201a192b47f1290ac6238bb64ec92ee (patch) | |
tree | 484b27d233873643a44fbae8e9aeda49f3edff61 /pp.c | |
parent | e4787c0c2a0ba73363e536994429000307f03526 (diff) | |
download | perl-ad6acfc4a201a192b47f1290ac6238bb64ec92ee.tar.gz |
Call get-magic once for defined ${...}
This example:
sub TIESCALAR { bless[]}
sub FETCH { warn "fetching"; "\cTAINT" }
tie my $a, "";
defined $$a;
prints ‘fetching’ three times in 5.8.8, five times (!) in 5.10-12,
four times in 5.14, and three times in blead as of ed996e63f6. Now it
only happens once.
It was commit 7a5fd60d4c that increased the number of fetches in 5.10,
but I haven’t checked which commits reduced it in 5.14.
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -286,10 +286,16 @@ Perl_softref2xv(pTHX_ SV *const sv, const char *const what, if ((PL_op->op_flags & OPf_SPECIAL) && !(PL_op->op_flags & OPf_MOD)) { - gv = gv_fetchsv(sv, 0, type); + STRLEN len; + const char * const nambeg = SvPV_nomg_const(sv, len); + gv = gv_fetchpvn_flags(nambeg, len, SvUTF8(sv), type); if (!gv && (!is_gv_magical_sv(sv,0) - || !(gv = gv_fetchsv(sv, GV_ADD, type)))) + || !(gv = gv_fetchpvn_flags( + nambeg, len, GV_ADD|SvUTF8(sv), type + )) + ) + ) { **spp = &PL_sv_undef; return NULL; |