Subject: | [PATCH] Improve Module::Build::Base::contains_pod(), which is a bottleneck |
Hi, xdg.
I have wrtie a patch to improve Module::Build::Base::contains_pod(),
which is a bottleneck in the Build script.
Regards,
--
Goro Fuji (gfx) GFUJI at CPAN.org
Subject: | cache-contains_pod.patch |
Index: lib/Module/Build/Base.pm
===================================================================
--- lib/Module/Build/Base.pm (revision 13772)
+++ lib/Module/Build/Base.pm (working copy)
@@ -3127,14 +3127,18 @@
sub contains_pod {
my ($self, $file) = @_;
- return '' unless -T $file; # Only look at text files
+ return $self->{_contains_pod}{$file}
+ if exists $self->{_contains_pod}{$file};
+
+ return $self->{_contains_pod}{$file} = '' if !-f $file;
+
my $fh = IO::File->new( $file ) or die "Can't open $file: $!";
- while (my $line = <$fh>) {
- return 1 if $line =~ /^\=(?:head|pod|item)/;
- }
+ binmode $fh; # for Win32
+ local $/ = undef; # slurp
- return '';
+ return $self->{_contains_pod}{$file}
+ = <$fh> =~ /^ = (?: head | pod | item ) /xms;
}
sub ACTION_html {