Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: b625025e93c87eab6565ea086e7d9c60245d6bd3
      
https://github.com/Perl/perl5/commit/b625025e93c87eab6565ea086e7d9c60245d6bd3
  Author: Richard Leach <[email protected]>
  Date:   2023-02-22 (Wed, 22 Feb 2023)

  Changed paths:
    M dist/Env/lib/Env.pm
    M lib/Benchmark.pm
    M lib/Class/Struct.pm
    M lib/overload.pm
    M lib/overload.t
    M lib/warnings.pm
    M regen/warnings.pl

  Log Message:
  -----------
  Prefer scalar assignment to get caller's first return value

Multiple forms of syntax can be used to obtain a package name from
`caller`, which emits this as its first return value, and assign
that name to a lexical scalar.

The following each achieve the same result, but with varying efficiency:
* `sub callme { my $package = caller(2); ...}`
* `sub callme { my ($package) = caller(2); ...}`
* `sub callme { my $package = (caller(2))[0]; ...}`

In the first example, `pp_caller` determines only the package name
and pushes it to the stack. In the other two examples, the other 10 of
`caller`'s return values are calculated and pushed onto the stack,
before being discarded.

This commit changes non-CPAN-first instances of the latter two forms
in core to the first form.

Note: There is a special exception to the equivalence described above,
when caller is use in list context within the DB package. Such a
usage instance in regen/warnings.pl therefore remains unchanged.


Reply via email to