Stop calling get-magic twice in pack "u", $utf8
authorFather Chrysostomos <sprout@cpan.org>
Fri, 31 Aug 2012 06:06:14 +0000 (23:06 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 31 Aug 2012 06:06:14 +0000 (23:06 -0700)
pp_pack.c
t/op/tie_fetch_count.t

index c9d9fcb..c760f69 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -3569,7 +3569,7 @@ extern const double _double_constants[];
            from_utf8 = DO_UTF8(fromstr);
            if (from_utf8) {
                aend = aptr + fromlen;
-               fromlen = sv_len_utf8(fromstr);
+               fromlen = sv_len_utf8_nomg(fromstr);
            } else aend = NULL; /* Unused, but keep compilers happy */
            GROWING(utf8, cat, start, cur, (fromlen+2) / 3 * 4 + (fromlen+len-1)/len * 2);
            while (fromlen > 0) {
index 48a070b..7ad375a 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 307);
+    plan (tests => 308);
 }
 
 use strict;
@@ -248,6 +248,10 @@ for ([chdir=>''],[chmod=>'0,'],[chown=>'0,0,'],[utime=>'0,0,'],
                             ; check_count 'select $tied_undef, ...';
 }
 
+chop(my $u = "\xff\x{100}");
+tie $var, "main", $u;
+$dummy  = pack "u", $var; check_count 'pack "u", $utf8';
+
 tie $var, "main", "\x{100}";
 pos$var = 0             ; check_count 'lvalue pos $utf8';
 $dummy  = substr$var,0,1; check_count 'substr $utf8';