From: Father Chrysostomos Date: Fri, 31 Aug 2012 05:34:38 +0000 (-0700) Subject: Stop calling get-magic twice when reading lvalue substr($utf8) X-Git-Tag: upstream/5.20.0~5539 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab445a1715227f3d5f9d67e34c119b0e772a9cb5;p=platform%2Fupstream%2Fperl.git Stop calling get-magic twice when reading lvalue substr($utf8) --- diff --git a/mg.c b/mg.c index 2de58e4..3dea5c2 100644 --- a/mg.c +++ b/mg.c @@ -2241,7 +2241,7 @@ Perl_magic_setsubstr(pTHX_ SV *sv, MAGIC *mg) Perl_ck_warner(aTHX_ packWARN(WARN_SUBSTR), "Attempt to use reference as lvalue in substr" ); - if (SvUTF8(lsv)) lsv_len = sv_len_utf8(lsv); + if (SvUTF8(lsv)) lsv_len = sv_len_utf8_nomg(lsv); else (void)SvPV_nomg(lsv,lsv_len); if (!translate_substr_offsets( lsv_len, diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index dfed65e..48a070b 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -7,7 +7,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan (tests => 306); + plan (tests => 307); } use strict; @@ -253,6 +253,7 @@ pos$var = 0 ; check_count 'lvalue pos $utf8'; $dummy = substr$var,0,1; check_count 'substr $utf8'; my $l =\substr$var,0,1; $dummy = $$l ; check_count 'reading lvalue substr($utf8)'; +$$l = 0 ; check_count 'setting lvalue substr($utf8)'; { local $SIG{__WARN__} = sub {};