=head1 NOTHING is faster in 5.10 Evar ArnfjErE Bjarmason =head1 split optimizations Handled by custom C code in C. Will never reach the regex engine (see B) =begin perl my @line = split /^/, $text; my @word = split /\s+/, $text; my @char = split //, $text; # NEW! # Hands in the air if you know what this does my @what = split ' ', $text; =end perl =head1 The benchmark =begin perl use Benchmark ':all'; my $str = ("hlagh" x 666); cmpthese(-1, { old => sub { split / /x, $str }, new => sub { split //, $str }, pack => sub { unpack "(a)*", $str }, }); =end perl =head1 Benchmark results The new C is around 3x faster than it was in 5.8.8 =begin perl old => sub { split / /x, $str }, new => sub { split //, $str }, pack => sub { unpack "(a)*", $str }, =end perl =begin text Rate old pack new old 182/s -- -61% -72% pack 473/s 160% -- -28% new 661/s 262% 40% -- =end text =cut =head1 The benchmark lies... ...unless you compiled with C<-DSTUPID_PATTERN_CHECKS> ./Configure -A ccflags=-DSTUPID_PATTERN_CHECKS =begin text $ perl5.9.5 -Mre=Debug,DUMP -e '//; /(?#I CAN HAS OPTIMIZE?!)/' Compiling REx "" Final program: 1: NOTHING (2) 2: END (0) minlen 0 Compiling REx "(?#I CAN HAS OPTIMIZE?!)" Final program: 1: NOTHING (2) 2: END (0) minlen 0 =end text =head1 split is rarely the bottleneck =begin perl old => sub { () = map { chr } split /(?:)/x, $str }, new => sub { () = map { chr } split //, $str }, pack => sub { () = unpack "(C)*", $str }, =end perl =begin text Rate old new pack old 80.7/s -- -31% -89% new 117/s 45% -- -84% pack 725/s 798% 518% -- =end text =cut