diff options
author | James E Keenan <jkeenan@cpan.org> | 2021-03-12 23:14:38 +0000 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2021-03-12 23:15:13 +0000 |
commit | a76080d5365f0f438160ff49a86aef2124fb2f17 (patch) | |
tree | f84d32f52e4ced82d209afd0322af26b11d5f584 | |
parent | 70d42808c1af2d989568601f4e1a45ea05102d50 (diff) | |
download | perl-a76080d5365f0f438160ff49a86aef2124fb2f17.tar.gz |
Eliminate double assignment from @_
In lib/Pod/Html.pm's get_cache(), the arguments from @_ were being read
into the file twice: once assigned to four distinct scalars, once to an
array. That array was in turn fed into an internal subroutine -- which
within itself assigned its elements to four distinct scalars.
sub get_cache {
my($dircache, $podpath, $podroot, $recurse) = @_;
my @cache_key_args = @_;
This approach may have made sense back in 1997 when the code first
entered the core distribution. Some of the four scalars were and are
used within get_cache(), while the array was at that time provided as
argument for two internal subroutines.
This approach, however, is of limited value today. We will likely to
want to bundle up all these lexical variables into a hash or an object
and just pass a single reference to internal subroutines. So let's
eliminate the double assignment and eliminate one variable.
Increment $VERSION.
-rw-r--r-- | ext/Pod-Html/lib/Pod/Html.pm | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm index b825acadca..e6c1a4a2fa 100644 --- a/ext/Pod-Html/lib/Pod/Html.pm +++ b/ext/Pod-Html/lib/Pod/Html.pm @@ -2,7 +2,7 @@ package Pod::Html; use strict; require Exporter; -our $VERSION = 1.26; +our $VERSION = 1.27; our @ISA = qw(Exporter); our @EXPORT = qw(pod2html htmlify); our @EXPORT_OK = qw(anchorify relativize_url); @@ -583,13 +583,12 @@ my $Saved_Cache_Key; sub get_cache { my($dircache, $podpath, $podroot, $recurse) = @_; - my @cache_key_args = @_; # A first-level cache: # Don't bother reading the cache files if they still apply # and haven't changed since we last read them. - my $this_cache_key = cache_key(@cache_key_args); + my $this_cache_key = cache_key($dircache, $podpath, $podroot, $recurse); return 1 if $Saved_Cache_Key and $this_cache_key eq $Saved_Cache_Key; $Saved_Cache_Key = $this_cache_key; |