diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-09 11:36:19 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-09 12:15:23 -0800 |
commit | 05a502dc1dc0cd21542a3e13fe0a9385fae70ec7 (patch) | |
tree | 61c90f25db7b000892cc99ab027cfd0b00ee5945 /sv.c | |
parent | 6ffceeb7a338e77238d41577677b09a402d84fa0 (diff) | |
download | perl-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.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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; |