summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-19 16:50:14 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:24 +0100
commit3cd2c7d486f06a3e4bc31c2f5afc51e5224fcac5 (patch)
tree64d973634771d438b68ec63a4ec9f4ac7e7908f0 /pp_hot.c
parent0b5aba47e85e02bdba9d9d90643d7928ac50cc80 (diff)
downloadperl-3cd2c7d486f06a3e4bc31c2f5afc51e5224fcac5.tar.gz
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.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/pp_hot.c b/pp_hot.c
index e2d9608ad8..a44ee34d9e 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -993,9 +993,12 @@ S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ)
|| ( PL_op->op_private & OPpMAYBE_TRUEBOOL
&& block_gimme() == G_VOID)
)
- && !tied
- )
- PUSHs(HvUSEDKEYS(hv) ? &PL_sv_yes : &PL_sv_zero);
+ ) {
+ if (tied)
+ PUSHs(Perl_hv_scalar(aTHX_ hv));
+ else
+ PUSHs(HvUSEDKEYS(hv) ? &PL_sv_yes : &PL_sv_zero);
+ }
else if (gimme == G_SCALAR) {
if (is_keys) {
IV i;