This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make 4-arg substr call FETCH once when upgrading target
authorFather Chrysostomos <sprout@cpan.org>
Sun, 30 Sep 2012 05:58:55 +0000 (22:58 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 1 Oct 2012 19:51:56 +0000 (12:51 -0700)
pp.c
t/op/tie_fetch_count.t

diff --git a/pp.c b/pp.c
index 171cb87..e91db87 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -3066,7 +3066,7 @@ PP(pp_substr)
        tmps = SvPV_force_nomg(sv, curlen);
        if (DO_UTF8(repl_sv) && repl_len) {
            if (!DO_UTF8(sv)) {
-               sv_utf8_upgrade(sv);
+               sv_utf8_upgrade_nomg(sv);
                curlen = SvCUR(sv);
            }
        }
index b5e4f90..240d23a 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 311);
+    plan (tests => 312);
 }
 
 use strict;
@@ -262,6 +262,8 @@ $dummy  = $$l           ; check_count 'reading lvalue substr($utf8)';
 $$l     = 0             ; check_count 'setting lvalue substr($utf8)';
 tie $var, "main", "a";
 $$l     = "\x{100}"     ; check_count 'assigning $utf8 to lvalue substr';
+tie $var1, "main", "a";
+substr$var1,0,0,"\x{100}"; check_count '4-arg substr with utf8 replacement';
 
 {
     local $SIG{__WARN__} = sub {};