summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-09 11:36:19 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-09 12:15:23 -0800
commit05a502dc1dc0cd21542a3e13fe0a9385fae70ec7 (patch)
tree61c90f25db7b000892cc99ab027cfd0b00ee5945 /sv.c
parent6ffceeb7a338e77238d41577677b09a402d84fa0 (diff)
downloadperl-05a502dc1dc0cd21542a3e13fe0a9385fae70ec7.tar.gz
Skip padsv op in $lex =~ ...
m//, s/// and y/// already have logic to deal with implicit lexical $_. The pad offset of $_ is stored in the match op itself. We can take advantage of that and extend it to lexical variables in general. That way we have fewer ops to execute, as $lex =~ // no longer calls pp_padsv. It also allows lexical variables’ names to be mentioned in uninitialized warnings for y///.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index 216ae76f95..e8db0534c6 100644
--- a/sv.c
+++ b/sv.c
@@ -15632,14 +15632,16 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
case OP_SUBST:
case OP_MATCH:
if ( !(obase->op_flags & OPf_STACKED)) {
- if (uninit_sv == ((obase->op_private & OPpTARGET_MY)
- ? PAD_SVl(obase->op_targ)
- : DEFSV))
+ if (uninit_sv == DEFSV)
{
sv = sv_newmortal();
sv_setpvs(sv, "$_");
return sv;
}
+ else if (obase->op_targ
+ && uninit_sv == PAD_SVl(obase->op_targ))
+ return varname(NULL, '$', obase->op_targ, NULL, 0,
+ FUV_SUBSCRIPT_NONE);
}
goto do_op;