From: Ævar Arnfjörð Bjarmason Date: Sat, 11 Aug 2007 20:33:49 +0000 (+0000) Subject: Re: [PATCH] Optimize split // X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e9515b0f73bee32254d01f1895ff1206459e6758;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] Optimize split // From: Ævar Arnfjörð Bjarmason Message-Id: <51dd1af80708111333kfd82e12u145b5ba38e23dcce@mail.gmail.com> p4raw-id: //depot/perl@31704 --- diff --git a/pp.c b/pp.c index 02e530f..54df53e 100644 --- a/pp.c +++ b/pp.c @@ -4726,26 +4726,36 @@ PP(pp_split) else EXTEND(SP, slen); - while (--limit) { - m = s; - - if (do_utf8) + if (do_utf8) { + while (--limit) { + /* keep track of how many bytes we skip over */ + m = s; s += UTF8SKIP(s); - else - ++s; + dstr = newSVpvn(m, s-m); - dstr = newSVpvn(m, s-m); + if (make_mortal) + sv_2mortal(dstr); - if (make_mortal) - sv_2mortal(dstr); - if (do_utf8) (void)SvUTF8_on(dstr); + PUSHs(dstr); - PUSHs(dstr); + if (s >= strend) + break; + } + } else { + while (--limit) { + dstr = newSVpvn(s, 1); + + s++; + + if (make_mortal) + sv_2mortal(dstr); - /* are we there yet? */ - if (s >= strend) - break; + PUSHs(dstr); + + if (s >= strend) + break; + } } } else if (do_utf8 == ((rx->extflags & RXf_UTF8) != 0) &&