This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
simplify keys(%tied_hash) in boolean context.
authorDavid Mitchell <davem@iabyn.com>
Wed, 19 Jul 2017 15:50:14 +0000 (16:50 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 27 Jul 2017 10:30:24 +0000 (11:30 +0100)
commit3cd2c7d486f06a3e4bc31c2f5afc51e5224fcac5
tree64d973634771d438b68ec63a4ec9f4ac7e7908f0
parent0b5aba47e85e02bdba9d9d90643d7928ac50cc80
simplify keys(%tied_hash) in boolean context.

Previously something like

    if (keys %tied_hash) { ... }

would have called FIRSTKEY(), followed by NEXTKEY() x N.

Now, it just calls SCALAR() once if present, and if not, falls
back to calling just FIRSTKEY() once.

i.e. it only needs to determine whether at least one key is present.

The behaviour of of 'keys(%tied) in boolean context now matches that of
'(%tied) in boolean context.

See http://nntp.perl.org/group/perl.perl5.porters/245463.
pp_hot.c
t/op/tie.t