pp_pack.c: Simplify sv length determination in one spot
authorFather Chrysostomos <sprout@cpan.org>
Mon, 1 Oct 2012 06:54:17 +0000 (23:54 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 1 Oct 2012 19:51:58 +0000 (12:51 -0700)
sv_len_utf8 is now careful not to record caches on magical or over-
loaded scalars (any non-PV, in fact).  It also returns the number of
logical characters correctly, regardless of whether its input is utf8.
So we can greatly simplify this code.

pp_pack.c

index c760f69..4f1a266 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2558,18 +2558,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
                if (lookahead.howlen == e_number) count = lookahead.length;
                else {
                    if (items > 0) {
-                       if (SvGAMAGIC(*beglist)) {
-                           /* Avoid reading the active data more than once
-                              by copying it to a temporary.  */
-                           STRLEN len;
-                           const char *const pv = SvPV_const(*beglist, len);
-                           SV *const temp
-                               = newSVpvn_flags(pv, len,
-                                                SVs_TEMP | SvUTF8(*beglist));
-                           *beglist = temp;
-                       }
-                       count = DO_UTF8(*beglist) ?
-                           sv_len_utf8(*beglist) : sv_len(*beglist);
+                       count = sv_len_utf8(*beglist);
                    }
                    else count = 0;
                    if (lookahead.code == 'Z') count++;