diff options
author | Ævar Arnfjörð Bjarmason <avar@cpan.org> | 2007-08-09 07:49:16 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-08-09 10:10:37 +0000 |
commit | 640f820da331e7bc688f3f8820b2760fa5a09de6 (patch) | |
tree | cb0dcb9ac4b8e2fc5c49fcd2c6db441d7469a37c /pp.c | |
parent | d3bf4b0e5207a91e509350df0ebcce4b2c9908f0 (diff) | |
download | perl-640f820da331e7bc688f3f8820b2760fa5a09de6.tar.gz |
Optimize split //
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Message-ID: <51dd1af80708090049p2cf4810ep5a437ad53f64fa78@mail.gmail.com>
p4raw-id: //depot/perl@31693
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -4711,6 +4711,43 @@ PP(pp_split) s = m; } } + else if (rx->extflags & RXf_NULL && !(s >= strend)) { + /* + Pre-extend the stack, either the number of bytes or + characters in the string or a limited amount, triggered by: + + my ($x, $y) = split //, $str; + or + split //, $str, $i; + */ + const U32 items = limit - 1; + if (items < slen) + EXTEND(SP, items); + else + EXTEND(SP, slen); + + while (--limit) { + m = s; + + if (do_utf8) + s += UTF8SKIP(s); + else + ++s; + + dstr = newSVpvn(m, s-m); + + if (make_mortal) + sv_2mortal(dstr); + if (do_utf8) + (void)SvUTF8_on(dstr); + + PUSHs(dstr); + + /* are we there yet? */ + if (s >= strend) + break; + } + } else if (do_utf8 == ((rx->extflags & RXf_UTF8) != 0) && (rx->extflags & RXf_USE_INTUIT) && !rx->nparens && (rx->extflags & RXf_CHECK_ALL) |