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

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

Thread Next
From:
James E Keenan via perl5-changes
Date:
March 12, 2021 23:24
Subject:
[Perl/perl5] a76080: Eliminate double assignment from @_
Message ID:
Perl/perl5/push/refs/heads/pod-html-duplicate-assignment-20210312/000000-a76080@github.com
  Branch: refs/heads/pod-html-duplicate-assignment-20210312
  Home:   https://github.com/Perl/perl5
  Commit: a76080d5365f0f438160ff49a86aef2124fb2f17
      https://github.com/Perl/perl5/commit/a76080d5365f0f438160ff49a86aef2124fb2f17
  Author: James E Keenan <jkeenan@cpan.org>
  Date:   2021-03-12 (Fri, 12 Mar 2021)

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

  Log Message:
  -----------
  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.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About