From 92cf6698b7b791604a155ab95762f0b29a351068 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 30 Aug 2012 22:26:33 -0700 Subject: [PATCH] Stop calling get-magic twice for lvalue pos($utf8) --- mg.c | 6 ++---- t/op/tie_fetch_count.t | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mg.c b/mg.c index 089f9c6..09f9b60 100644 --- a/mg.c +++ b/mg.c @@ -2166,7 +2166,7 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) pos = SvIV(sv); if (DO_UTF8(lsv)) { - ulen = sv_len_utf8(lsv); + ulen = sv_len_utf8_nomg(lsv); if (ulen) len = ulen; } @@ -2180,9 +2180,7 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) pos = len; if (ulen) { - I32 p = pos; - sv_pos_u2b(lsv, &p, 0); - pos = p; + pos = sv_pos_u2b_flags(lsv, pos, 0, 0); } found->mg_len = pos; diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index 9cadaf6..977b8bf 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 => 304); + plan (tests => 305); } use strict; @@ -248,7 +248,8 @@ for ([chdir=>''],[chmod=>'0,'],[chown=>'0,0,'],[utime=>'0,0,'], ; check_count 'select $tied_undef, ...'; } -$var = "\x{100}"; +tie $var, "main", "\x{100}"; +pos$var = 0 ; check_count 'lvalue pos $utf8'; $dummy = substr$var,0,1; check_count 'substr $utf8'; { -- 2.7.4