There doesn't seem to be a significant difference between the [AaEeIiOoUu]{2} and [AaEeIiOoUu][AaEeIiOoUu] variations under Strawberry 5.14.4, but I was a bit surprised that there's so little improvement over the /i version.
c:\@Work\Perl\monks>perl -wMstrict -le
"use Benchmark qw(cmpthese);
;;
print 'Perl version: ', $];
;;
my $s = 'Aid bears out ';
$s = $s x 10_000_000;
print 'length: ', length $s;
;;
cmpthese(-1, {
'/i' => sub { $s =~ m{ (?i) [aeiou]{2} }xmsg },
'[Aa]{2}' => sub { $s =~ m{ [AaEeIiOoUu]{2} }xmsg },
'[Aa][Aa]' => sub { $s =~ m{ [AaEeIiOoUu][AaEeIiOoUu] }xmsg },
});
"
Perl version: 5.014004
length: 140000000
Rate /i [Aa]{2} [Aa][Aa]
/i 3276565/s -- -8% -9%
[Aa]{2} 3558515/s 9% -- -1%
[Aa][Aa] 3600879/s 10% 1% --
The results are closer to what you suggest under ActiveState 5.8.9, but with /i still surprisingly high.
c:\@Work\Perl>perl -wMstrict -le
"(source code as above)
"
Perl version: 5.008009
length: 140000000
Rate [Aa]{2} /i [Aa][Aa]
[Aa]{2} 3276565/s -- -6% -16%
/i 3480139/s 6% -- -11%
[Aa][Aa] 3918166/s 20% 13% --
Still, as you say, it's a bit of a micro-optimization.
|