diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-08-31 09:05:50 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-08-31 09:05:50 +0000 |
commit | 78c72037c327e2cd8ede6cf098324435a670ca67 (patch) | |
tree | a16b884a1b38e00a54fe96eb7fe890408d6abb13 /pp.c | |
parent | 2e0df0e80ba5355d269a0006da239be95c70765d (diff) | |
download | perl-78c72037c327e2cd8ede6cf098324435a670ca67.tar.gz |
Change the generation of {} and [] from 3 ops to 1, and avoid 1 mortal
on the tempstack, by augmenting pp_anonlist and pp_anonhash to accept
OPf_SPECIAL to mean "return a reference to the aggregate" on the stack
rather than the aggregate itself.
p4raw-id: //depot/perl@28771
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -4123,16 +4123,17 @@ PP(pp_anonlist) { dVAR; dSP; dMARK; dORIGMARK; const I32 items = SP - MARK; - SV * const av = sv_2mortal((SV*)av_make(items, MARK+1)); + SV * const av = (SV *) av_make(items, MARK+1); SP = ORIGMARK; /* av_make() might realloc stack_sp */ - XPUSHs(av); + XPUSHs(sv_2mortal((PL_op->op_flags & OPf_SPECIAL) + ? newRV_noinc(av) : av)); RETURN; } PP(pp_anonhash) { dVAR; dSP; dMARK; dORIGMARK; - HV* const hv = (HV*)sv_2mortal((SV*)newHV()); + HV* const hv = newHV(); while (MARK < SP) { SV * const key = *++MARK; @@ -4144,7 +4145,8 @@ PP(pp_anonhash) (void)hv_store_ent(hv,key,val,0); } SP = ORIGMARK; - XPUSHs((SV*)hv); + XPUSHs(sv_2mortal((PL_op->op_flags & OPf_SPECIAL) + ? newRV_noinc((SV*) hv) : (SV*)hv)); RETURN; } |