From: Karl Date: Sun, 18 Jan 2009 22:34:58 +0000 (-0700) Subject: Combine sv_utf8_upgrade with a following grow X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7bf7986364dc86acb86c5d83e7512b8dbdcb0165;p=p5sagit%2Fp5-mst-13.2.git Combine sv_utf8_upgrade with a following grow --- diff --git a/pp_ctl.c b/pp_ctl.c index e9b4bfc..799683d 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -511,8 +511,7 @@ PP(pp_formline) if (!targ_is_utf8 && DO_UTF8(tmpForm)) { SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget)); *t = '\0'; - sv_utf8_upgrade(PL_formtarget); - SvGROW(PL_formtarget, SvCUR(PL_formtarget) + fudge + 1); + sv_utf8_upgrade_flags_grow(PL_formtarget, SV_GMAGIC, fudge + 1); t = SvEND(PL_formtarget); targ_is_utf8 = TRUE; } @@ -695,8 +694,8 @@ PP(pp_formline) if (!targ_is_utf8) { SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget)); *t = '\0'; - sv_utf8_upgrade(PL_formtarget); - SvGROW(PL_formtarget, SvCUR(PL_formtarget) + fudge + 1); + sv_utf8_upgrade_flags_grow(PL_formtarget, SV_GMAGIC, + fudge + 1); t = SvEND(PL_formtarget); targ_is_utf8 = TRUE; } @@ -807,7 +806,7 @@ PP(pp_formline) t - SvPVX_const(PL_formtarget)); targ_is_utf8 = TRUE; /* Don't need get magic. */ - sv_utf8_upgrade_flags(PL_formtarget, 0); + sv_utf8_upgrade_nomg(PL_formtarget); } else { SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget)); diff --git a/sv.c b/sv.c index 0d6939f..d944e2f 100644 --- a/sv.c +++ b/sv.c @@ -4796,7 +4796,8 @@ Perl_sv_catsv_flags(pTHX_ SV *const dsv, register SV *const ssv, const I32 flags spv = SvPV_const(csv, slen); } else - sv_utf8_upgrade_nomg(dsv); + /* Leave enough space for the cat that's about to happen */ + sv_utf8_upgrade_flags_grow(dsv, 0, slen); } sv_catpvn_nomg(dsv, spv, slen); } diff --git a/toke.c b/toke.c index 258c927..951c1ca 100644 --- a/toke.c +++ b/toke.c @@ -2306,9 +2306,10 @@ S_scan_const(pTHX_ char *start) SvCUR_set(sv, d - SvPVX_const(sv)); SvPOK_on(sv); *d = '\0'; - sv_utf8_upgrade(sv); /* See Note on sizing above. */ - SvGROW(sv, SvCUR(sv) + UNISKIP(uv) + (STRLEN)(send - s) + 1); + sv_utf8_upgrade_flags_grow(sv, + SV_GMAGIC|SV_FORCE_UTF8_UPGRADE, + UNISKIP(uv) + (STRLEN)(send - s) + 1); d = SvPVX(sv) + SvCUR(sv); has_utf8 = TRUE; } @@ -2396,9 +2397,10 @@ S_scan_const(pTHX_ char *start) SvCUR_set(sv, d - SvPVX_const(sv)); SvPOK_on(sv); *d = '\0'; - sv_utf8_upgrade(sv); /* See Note on sizing above. */ - SvGROW(sv, SvCUR(sv) + len + (STRLEN)(send - s) + 1); + sv_utf8_upgrade_flags_grow(sv, + SV_GMAGIC|SV_FORCE_UTF8_UPGRADE, + len + (STRLEN)(send - s) + 1); d = SvPVX(sv) + SvCUR(sv); has_utf8 = TRUE; } else if (len > (STRLEN)(e - s + 4)) { /* I _guess_ 4 is \N{} --jhi */ @@ -2490,10 +2492,10 @@ S_scan_const(pTHX_ char *start) SvCUR_set(sv, d - SvPVX_const(sv)); SvPOK_on(sv); *d = '\0'; - sv_utf8_upgrade(sv); - /* See Note on sizing above. */ - SvGROW(sv, SvCUR(sv) + need + (STRLEN)(send - s) + 1); + sv_utf8_upgrade_flags_grow(sv, + SV_GMAGIC|SV_FORCE_UTF8_UPGRADE, + need + (STRLEN)(send - s) + 1); d = SvPVX(sv) + SvCUR(sv); has_utf8 = TRUE; } else if (need > len) {