diff options
author | David Mitchell <davem@iabyn.com> | 2017-07-17 17:51:57 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-07-27 11:30:24 +0100 |
commit | af3b1cba4fa1f9302496ccf5135bf61703227009 (patch) | |
tree | d84ea620b9bf30b1356fc690e4d1313f94ba0cfa /pp_hot.c | |
parent | e84e4286916d8a219c8a63468807b41df9cde7fe (diff) | |
download | perl-af3b1cba4fa1f9302496ccf5135bf61703227009.tar.gz |
create Perl_hv_pushkv() function
...and make pp_padhv(), pp_rv2hv() use it rather than using Perl_do_kv()
Both pp_padhv() and pp_rv2hv() (via S_padhv_rv2hv_common()), outsource to
Perl_do_kv(), the list-context pushing/flattening of a hash onto the
stack.
Perl_do_kv() is a big function that handles all the actions of
keys, values etc. Instead, create a new function which does just the
pushing of a hash onto the stack.
At the same time, split it out into two loops, one for tied, one for
normal: the untied one can skip extending the stack on each iteration,
and use a cheaper HeVAL() instead of calling hv_iterval().
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -968,7 +968,7 @@ PP(pp_print) /* do the common parts of pp_padhv() and pp_rv2hv() * It assumes the caller has done EXTEND(SP, 1) or equivalent. - * 'is_keys' indicates the OPpPADHV_ISKEYS/OPpRV2HV_ISKEYS flag is set + * 'is_keys' indicates the OPpPADHV_ISKEYS/OPpRV2HV_ISKEYS flag is set. * 'has_targ' indicates that the op has a target - this should * be a compile-time constant so that the code can constant-folded as * appropriate @@ -983,9 +983,8 @@ S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ) assert(PL_op->op_type == OP_PADHV || PL_op->op_type == OP_RV2HV); if (gimme == G_ARRAY) { - PUSHs(MUTABLE_SV(hv)); - PUTBACK; - return Perl_do_kv(aTHX); + hv_pushkv(hv); + return NORMAL; } if (is_keys) |