From 571f0e8653a532c34edde36e797ecba446978b1c Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 14 Jun 2011 17:52:46 +0200 Subject: [PATCH] pos in lvalue context now returns a PVMG instead of a PVLV. Store the target SV in mg_obj, instead of LvTARG(). This slightly reduces both code complexity and runtime memory use. --- mg.c | 6 ++---- pod/perldelta.pod | 5 +++++ pp.c | 6 ++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mg.c b/mg.c index 1bdf5c4..64c7d20 100644 --- a/mg.c +++ b/mg.c @@ -2064,10 +2064,9 @@ int Perl_magic_getpos(pTHX_ SV *sv, MAGIC *mg) { dVAR; - SV* const lsv = LvTARG(sv); + SV *const lsv = mg->mg_obj; PERL_ARGS_ASSERT_MAGIC_GETPOS; - PERL_UNUSED_ARG(mg); if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv)) { MAGIC * const found = mg_find(lsv, PERL_MAGIC_regex_global); @@ -2087,14 +2086,13 @@ int Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) { dVAR; - SV* const lsv = LvTARG(sv); + SV *const lsv = mg->mg_obj; SSize_t pos; STRLEN len; STRLEN ulen = 0; MAGIC* found; PERL_ARGS_ASSERT_MAGIC_SETPOS; - PERL_UNUSED_ARG(mg); if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv)) found = mg_find(lsv, PERL_MAGIC_regex_global); diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 8684157..e067934 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -766,6 +766,11 @@ stored via the mg_ptr of their PERL_MAGIC_bm. Previously they were PVGVs, with the tables stored in the string buffer, beyond SvLEN(). This eliminates the last place where the core stores data beyond SvLEN(). +=item * + +C in lvalue context now returns a PVMG instead of a PVLV, storing the +target SV in C, instead of C. + =back =head1 Selected Bug Fixes diff --git a/pp.c b/pp.c index 385f1be..f87e0dd 100644 --- a/pp.c +++ b/pp.c @@ -361,10 +361,8 @@ PP(pp_pos) dVAR; dSP; dPOPss; if (PL_op->op_flags & OPf_MOD || LVRET) { - SV * const ret = sv_2mortal(newSV_type(SVt_PVLV)); /* Not TARG RT#67838 */ - sv_magic(ret, NULL, PERL_MAGIC_pos, NULL, 0); - LvTYPE(ret) = '.'; - LvTARG(ret) = SvREFCNT_inc_simple(sv); + SV * const ret = sv_2mortal(newSV_type(SVt_PVMG)); /* Not TARG RT#67838 */ + sv_magic(ret, sv, PERL_MAGIC_pos, NULL, 0); PUSHs(ret); /* no SvSETMAGIC */ RETURN; } -- 2.7.4