develooper Front page | perl.perl5.changes | Postings from March 2021

[Perl/perl5] a76080: Eliminate double assignment from @_

Thread Next
James E Keenan via perl5-changes
March 12, 2021 23:24
[Perl/perl5] a76080: Eliminate double assignment from @_
Message ID:
  Branch: refs/heads/pod-html-duplicate-assignment-20210312
  Commit: a76080d5365f0f438160ff49a86aef2124fb2f17
  Author: James E Keenan <>
  Date:   2021-03-12 (Fri, 12 Mar 2021)

  Changed paths:
    M ext/Pod-Html/lib/Pod/

  Log Message:
  Eliminate double assignment from @_

In lib/Pod/'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.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About