diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2021-01-30 04:38:25 +0000 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-02-09 08:34:06 -0800 |
commit | fa3bc4a32c3d8e7ca6fc27d71694893cc33b6858 (patch) | |
tree | aadaf8dbed4a9b2c6a00235cd4ae83e00344b26c /pp.c | |
parent | 71b07aa842287fc28b95c3f8aebb0912fad16ea4 (diff) | |
download | perl-fa3bc4a32c3d8e7ca6fc27d71694893cc33b6858.tar.gz |
pp_split: reduce new SV flag computations
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 32 |
1 files changed, 13 insertions, 19 deletions
@@ -6012,7 +6012,8 @@ PP(pp_split) const U8 gimme = GIMME_V; bool gimme_scalar; I32 oldsave = PL_savestack_ix; - U32 make_mortal = SVs_TEMP; + U32 flags = (do_utf8 ? SVf_UTF8 : 0) | + SVs_TEMP; /* Make mortal SVs by default */ bool multiline = 0; MAGIC *mg = NULL; @@ -6053,7 +6054,7 @@ PP(pp_split) PUSHMARK(SP); XPUSHs(SvTIED_obj(MUTABLE_SV(ary), mg)); } else { - make_mortal = 0; + flags &= ~SVs_TEMP; /* SVs will not be mortal */ } } @@ -6121,8 +6122,7 @@ PP(pp_split) else trailing_empty = 0; } else { - dstr = newSVpvn_flags(s, m-s, - (do_utf8 ? SVf_UTF8 : 0) | make_mortal); + dstr = newSVpvn_flags(s, m-s, flags); XPUSHs(dstr); } @@ -6166,8 +6166,7 @@ PP(pp_split) else trailing_empty = 0; } else { - dstr = newSVpvn_flags(s, m-s, - (do_utf8 ? SVf_UTF8 : 0) | make_mortal); + dstr = newSVpvn_flags(s, m-s, flags); XPUSHs(dstr); } s = m; @@ -6211,12 +6210,12 @@ PP(pp_split) while (--limit) { m = s; s += UTF8SKIP(s); - dstr = newSVpvn_flags(m, s-m, SVf_UTF8 | make_mortal); + dstr = newSVpvn_flags(m, s-m, flags); PUSHs(dstr); } } else { while (--limit) { - dstr = newSVpvn_flags(s, 1, make_mortal); + dstr = newSVpvn_flags(s, 1, flags); PUSHs(dstr); s++; } @@ -6245,8 +6244,7 @@ PP(pp_split) else trailing_empty = 0; } else { - dstr = newSVpvn_flags(s, m-s, - (do_utf8 ? SVf_UTF8 : 0) | make_mortal); + dstr = newSVpvn_flags(s, m-s, flags); XPUSHs(dstr); } /* The rx->minlen is in characters but we want to step @@ -6269,8 +6267,7 @@ PP(pp_split) else trailing_empty = 0; } else { - dstr = newSVpvn_flags(s, m-s, - (do_utf8 ? SVf_UTF8 : 0) | make_mortal); + dstr = newSVpvn_flags(s, m-s, flags); XPUSHs(dstr); } /* The rx->minlen is in characters but we want to step @@ -6306,8 +6303,7 @@ PP(pp_split) else trailing_empty = 0; } else { - dstr = newSVpvn_flags(s, m-s, - (do_utf8 ? SVf_UTF8 : 0) | make_mortal); + dstr = newSVpvn_flags(s, m-s, flags); XPUSHs(dstr); } if (RX_NPARENS(rx)) { @@ -6327,9 +6323,7 @@ PP(pp_split) trailing_empty = 0; } else { if (m >= orig && s >= orig) { - dstr = newSVpvn_flags(s, m-s, - (do_utf8 ? SVf_UTF8 : 0) - | make_mortal); + dstr = newSVpvn_flags(s, m-s, flags); } else dstr = &PL_sv_undef; /* undef, not "" */ @@ -6352,7 +6346,7 @@ PP(pp_split) if (s < strend || (iters && origlimit)) { if (!gimme_scalar) { const STRLEN l = strend - s; - dstr = newSVpvn_flags(s, l, (do_utf8 ? SVf_UTF8 : 0) | make_mortal); + dstr = newSVpvn_flags(s, l, flags); XPUSHs(dstr); } iters++; @@ -6362,7 +6356,7 @@ PP(pp_split) iters -= trailing_empty; } else { while (iters > 0 && (!TOPs || !SvANY(TOPs) || SvCUR(TOPs) == 0)) { - if (TOPs && !make_mortal) + if (TOPs && !(flags & SVs_TEMP)) sv_2mortal(TOPs); *SP-- = NULL; iters--; |