From: Vincent Pit Date: Sun, 29 Jul 2012 10:02:35 +0000 (+0200) Subject: Only compile $PKG_REGEXP and $VERS_REGEXP once X-Git-Tag: release_1.0.10~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=69859aa0088eb7050955af2e0549aab8029d1064;p=p5sagit%2FModule-Metadata.git Only compile $PKG_REGEXP and $VERS_REGEXP once These regexps are static and so can benefit from the /o modifier. Profiling shows that this gives a 15% speedup for _parse_fh(). --- diff --git a/lib/Module/Metadata.pm b/lib/Module/Metadata.pm index a7e7234..e3c12e3 100644 --- a/lib/Module/Metadata.pm +++ b/lib/Module/Metadata.pm @@ -420,7 +420,7 @@ sub _parse_version_expression { my $line = shift; my( $sig, $var, $pkg ); - if ( $line =~ $VERS_REGEXP ) { + if ( $line =~ /$VERS_REGEXP/o ) { ( $sig, $var, $pkg ) = $2 ? ( $1, $2, $3 ) : ( $4, $5, $6 ); if ( $pkg ) { $pkg = ($pkg eq '::') ? 'main' : $pkg; @@ -492,7 +492,7 @@ sub _parse_fh { ? $self->_parse_version_expression( $line ) : (); - if ( $line =~ $PKG_REGEXP ) { + if ( $line =~ /$PKG_REGEXP/o ) { $pkg = $1; push( @pkgs, $pkg ) unless grep( $pkg eq $_, @pkgs ); $vers{$pkg} = (defined $2 ? $2 : undef) unless exists( $vers{$pkg} );