memo
This is perl, v5.8.8 built for i386-linux
#!/usr/bin/perl use strict; use warnings; use Benchmark qw(:all); cmpthese( -2 , { hatena => sub { my $str = 'hogehoge2r'; $str =~ s/(?:2r|3|3r)$//; }, nohatena => sub { my $str = 'hogehoge2r'; $str =~ s/(2r|3|3r)$//; }, ushironihatena => sub { my $str = 'hogehoge2r'; $str =~ s/(2r|3r?)$//; } });
hatena 514864/s -- -57% -61% nohatena 1190866/s 131% -- -9% ushironihatena 1310720/s 155% 10% --