summaryrefslogtreecommitdiff
path: root/Porting/pod_lib.pl
diff options
context:
space:
mode:
Diffstat (limited to 'Porting/pod_lib.pl')
-rw-r--r--Porting/pod_lib.pl40
1 files changed, 24 insertions, 16 deletions
diff --git a/Porting/pod_lib.pl b/Porting/pod_lib.pl
index e241208751..a40bdb4d3b 100644
--- a/Porting/pod_lib.pl
+++ b/Porting/pod_lib.pl
@@ -48,14 +48,30 @@ my %state = (
my %Readmepods;
-my (%Lengths, %MD5s);
-
-sub is_duplicate_pod {
- my $file = shift;
- # We are a file in lib. Are we a duplicate?
- # Don't bother calculating the MD5 if there's no interesting file of
- # this length.
- return $Lengths{-s $file} && $MD5s{md5(slurp_or_die($file))};
+{
+ my (%Lengths, %MD5s);
+
+ sub is_duplicate_pod {
+ my $file = shift;
+
+ # Initialise the list of possible source files on the first call.
+ unless (%Lengths) {
+ __prime_state() unless $state{master};
+ foreach (@{$state{master}}) {
+ next if !$_ || @$_ < 4 || $_->[1] eq $_->[4];
+ # This is a dual-life perl*.pod file, which will have be copied
+ # to lib/ by the build process, and hence also found there.
+ # These are the only pod files that might become duplicated.
+ ++$Lengths{-s $_->[2]};
+ ++$MD5s{md5(slurp_or_die($_->[2]))};
+ }
+ }
+
+ # We are a file in lib. Are we a duplicate?
+ # Don't bother calculating the MD5 if there's no interesting file of
+ # this length.
+ return $Lengths{-s $file} && $MD5s{md5(slurp_or_die($file))};
+ }
}
sub __prime_state {
@@ -119,14 +135,6 @@ sub __prime_state {
my_die "Unknown flag found in section line: $_" if length $flags;
my ($leafname) = $podname =~ m!([^/]+)$!;
- if ($leafname ne $podname) {
- # We are a dual-life perl*.pod file, which will have be copied
- # to lib/ by the build process, and hence also found there.
- # These are the only pod files that might become duplicated.
- ++$Lengths{-s $filename};
- ++$MD5s{md5(slurp_or_die($filename))};
- }
-
push @{$state{master}},
[\%flags, $podname, $filename, $desc, $leafname];
} elsif (/^$/) {