summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-19 17:06:28 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:24 +0100
commite1ad5d4c666831a6890bdfd5b332e1bf64677f89 (patch)
treea519a8025cdb669558899767445d78ed4ca09b8a /pp_hot.c
parent3cd2c7d486f06a3e4bc31c2f5afc51e5224fcac5 (diff)
downloadperl-e1ad5d4c666831a6890bdfd5b332e1bf64677f89.tar.gz
S_padhv_rv2hv_common(): unroll hv_scalar() calls
This function makes a couple of calls to hv_scalar(), which does one of two things depending on whether hash is tied or not. Since in S_padhv_rv2hv_common() we've already determined whether the hash is tied, just include the relevant part(s) of hv_scalar() directly. The code will be reorganised shortly.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/pp_hot.c b/pp_hot.c
index a44ee34d9e..233d4d4ec2 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -974,6 +974,7 @@ PERL_STATIC_INLINE OP*
S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ)
{
bool tied;
+ MAGIC *mg;
dSP;
assert(PL_op->op_type == OP_PADHV || PL_op->op_type == OP_RV2HV);
@@ -987,7 +988,7 @@ S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ)
/* 'keys %h' masquerading as '%h': reset iterator */
(void)hv_iterinit(hv);
- tied = SvRMAGICAL(hv) && mg_find(MUTABLE_SV(hv), PERL_MAGIC_tied);
+ tied = SvRMAGICAL(hv) && (mg = mg_find(MUTABLE_SV(hv), PERL_MAGIC_tied));
if ( ( PL_op->op_private & OPpTRUEBOOL
|| ( PL_op->op_private & OPpMAYBE_TRUEBOOL
@@ -995,7 +996,7 @@ S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ)
)
) {
if (tied)
- PUSHs(Perl_hv_scalar(aTHX_ hv));
+ PUSHs(magic_scalarpack(hv, mg));
else
PUSHs(HvUSEDKEYS(hv) ? &PL_sv_yes : &PL_sv_zero);
}
@@ -1016,8 +1017,12 @@ S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ)
else
mPUSHi(i);
}
- else
- PUSHs(Perl_hv_scalar(aTHX_ hv));
+ else {
+ if (tied)
+ PUSHs(magic_scalarpack(hv, mg));
+ else
+ mPUSHi(HvUSEDKEYS(hv));
+ }
}
PUTBACK;