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

[Perl/perl5] 09cd3e: Eliminate more uses of `XPVHV* xhv;` to cache`(XP...

Nicholas Clark via perl5-changes
October 12, 2021 06:14
[Perl/perl5] 09cd3e: Eliminate more uses of `XPVHV* xhv;` to cache`(XP...
Message ID:
  Branch: refs/heads/blead
  Commit: 09cd3e1cbb58c83075231a9d80a523ef3631faee
  Author: Nicholas Clark <>
  Date:   2021-10-11 (Mon, 11 Oct 2021)

  Changed paths:
    M hv.c

  Log Message:
  Eliminate more uses of `XPVHV* xhv;` to cache `(XPVHV*)SvANY(hv)`

Similar to commit 4b6b6165ecccd54b, Perl_hv_clear() should instead read
HvMAX(hv) into a local variable.

Most other remaining uses no longer saved repeated dereferences, so
eliminate the verbosity and replace the explicit dereference with the normal
macro (and in some cases delete the comment which echos the macro).

In S_hv_free_entries() use HvTOTALKEYS(hv) directly. Whilst this is
potentially performing the deference of SvANY(hv) more than once, the
structure of the code is such that this will only happen on the last
iteration of the loop, or on the unlikely event that the hash contained NULL
values. (Such hashes are not legal in "Perl" space, but XS code can create
them.) Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About