From a4036ec1a2044ae2d677ec3df30cde04dd5a008a Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 30 Aug 2012 22:30:26 -0700 Subject: [PATCH] Stop calling get-magic twice when reading lvalue substr($utf8) --- mg.c | 2 +- t/op/tie_fetch_count.t | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mg.c b/mg.c index 09f9b60..2de58e4 100644 --- a/mg.c +++ b/mg.c @@ -2204,7 +2204,7 @@ Perl_magic_getsubstr(pTHX_ SV *sv, MAGIC *mg) PERL_UNUSED_ARG(mg); if (!translate_substr_offsets( - SvUTF8(lsv) ? sv_len_utf8(lsv) : len, + SvUTF8(lsv) ? sv_len_utf8_nomg(lsv) : len, negoff ? -(IV)offs : (IV)offs, !negoff, negrem ? -(IV)rem : (IV)rem, !negrem, &offs, &rem )) { diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index 977b8bf..dfed65e 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 => 305); + plan (tests => 306); } use strict; @@ -251,6 +251,8 @@ for ([chdir=>''],[chmod=>'0,'],[chown=>'0,0,'],[utime=>'0,0,'], tie $var, "main", "\x{100}"; 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)'; { local $SIG{__WARN__} = sub {}; -- 1.8.3.1