diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-12-19 16:05:15 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-12-19 16:30:39 -0800 |
commit | 82334630454b4b4e55257e3bf48f998a8a2814a9 (patch) | |
tree | b81f353fabe8a3000578973d00d833e9905430cc | |
parent | 54408af452c3b8791b74227d549ac4a2d660d916 (diff) | |
download | perl-82334630454b4b4e55257e3bf48f998a8a2814a9.tar.gz |
Use GIMME_V in preference to GIMME
GIMME_V is a simpler macro that results in smaller machine code.
GIMME does not distinguish between scalar and void context. The two
instances of GIMME == G_SCALAR that I changed (which used to match
void context too, but no longer do) are in code paths unreachable in
void context, so we don’t need to check for it.
-rw-r--r-- | op.h | 4 | ||||
-rw-r--r-- | pp.c | 28 | ||||
-rw-r--r-- | pp_ctl.c | 10 | ||||
-rw-r--r-- | pp_hot.c | 2 | ||||
-rw-r--r-- | pp_sort.c | 2 | ||||
-rw-r--r-- | pp_sys.c | 24 |
6 files changed, 36 insertions, 34 deletions
@@ -150,12 +150,14 @@ Deprecated. Use C<GIMME_V> instead. #define OPf_LIST OPf_WANT_LIST #define OPf_KNOW OPf_WANT -#define GIMME \ +#ifndef PERL_CORE +# define GIMME \ (PL_op->op_flags & OPf_WANT \ ? ((PL_op->op_flags & OPf_WANT) == OPf_WANT_LIST \ ? G_ARRAY \ : G_SCALAR) \ : dowantarray()) +#endif /* NOTE: OPp* flags are now auto-generated and defined in opcode.h, @@ -78,7 +78,7 @@ PP(pp_padav) } else if (PL_op->op_private & OPpMAYBE_LVSUB) { const I32 flags = is_lvalue_sub(); if (flags && !(flags & OPpENTERSUB_INARGS)) { - if (GIMME == G_SCALAR) + if (GIMME_V == G_SCALAR) /* diag_listed_as: Can't return %s to lvalue scalar context */ Perl_croak(aTHX_ "Can't return array to lvalue scalar context"); PUSHs(TARG); @@ -130,7 +130,7 @@ PP(pp_padhv) else if (PL_op->op_private & OPpMAYBE_LVSUB) { const I32 flags = is_lvalue_sub(); if (flags && !(flags & OPpENTERSUB_INARGS)) { - if (GIMME == G_SCALAR) + if (GIMME_V == G_SCALAR) /* diag_listed_as: Can't return %s to lvalue scalar context */ Perl_croak(aTHX_ "Can't return hash to lvalue scalar context"); RETURN; @@ -533,7 +533,7 @@ PP(pp_srefgen) PP(pp_refgen) { dSP; dMARK; - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { if (++MARK <= SP) *MARK = *SP; else @@ -1640,7 +1640,7 @@ PP(pp_repeat) IV count; SV *sv; - if (GIMME == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) { + if (GIMME_V == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) { /* TODO: think of some way of doing list-repeat overloading ??? */ sv = POPs; SvGETMAGIC(sv); @@ -1696,7 +1696,7 @@ PP(pp_repeat) "Negative repeat count does nothing"); } - if (GIMME == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) { + if (GIMME_V == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) { dMARK; static const char* const oom_list_extend = "Out of memory during list extend"; const I32 items = SP - MARK; @@ -4445,7 +4445,7 @@ PP(pp_aslice) *MARK = svp ? *svp : &PL_sv_undef; } } - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { MARK = ORIGMARK; *++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef; SP = MARK; @@ -4490,7 +4490,7 @@ PP(pp_kvaslice) } *++MARK = svp ? *svp : &PL_sv_undef; } - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { MARK = SP - items*2; *++MARK = items > 0 ? *SP : &PL_sv_undef; SP = MARK; @@ -4891,7 +4891,7 @@ PP(pp_hslice) } *MARK = svp && *svp ? *svp : &PL_sv_undef; } - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { MARK = ORIGMARK; *++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef; SP = MARK; @@ -4940,7 +4940,7 @@ PP(pp_kvhslice) } *++MARK = svp && *svp ? *svp : &PL_sv_undef; } - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { MARK = SP - items*2; *++MARK = items > 0 ? *SP : &PL_sv_undef; SP = MARK; @@ -4953,7 +4953,7 @@ PP(pp_kvhslice) PP(pp_list) { I32 markidx = POPMARK; - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { SV **mark = PL_stack_base + markidx; dSP; if (++MARK <= SP) @@ -4978,7 +4978,7 @@ PP(pp_lslice) const I32 max = lastrelem - lastlelem; SV **lelem; - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { I32 ix = SvIV(*lastlelem); if (ix < 0) ix += max; @@ -5163,7 +5163,7 @@ PP(pp_splice) } MARK = ORIGMARK + 1; - if (GIMME == G_ARRAY) { /* copy return vals to stack */ + if (GIMME_V == G_ARRAY) { /* copy return vals to stack */ const bool real = cBOOL(AvREAL(ary)); MEXTEND(MARK, length); if (real) @@ -5259,7 +5259,7 @@ PP(pp_splice) } MARK = ORIGMARK + 1; - if (GIMME == G_ARRAY) { /* copy return vals to stack */ + if (GIMME_V == G_ARRAY) { /* copy return vals to stack */ if (length) { const bool real = cBOOL(AvREAL(ary)); if (real) @@ -5382,7 +5382,7 @@ PP(pp_reverse) { dSP; dMARK; - if (GIMME == G_ARRAY) { + if (GIMME_V == G_ARRAY) { if (PL_op->op_private & OPpREVERSE_INPLACE) { AV *av; @@ -1109,7 +1109,7 @@ PP(pp_mapwhile) PP(pp_range) { - if (GIMME == G_ARRAY) + if (GIMME_V == G_ARRAY) return NORMAL; if (SvTRUEx(PAD_SV(PL_op->op_targ))) return cLOGOP->op_other; @@ -1121,7 +1121,7 @@ PP(pp_flip) { dSP; - if (GIMME == G_ARRAY) { + if (GIMME_V == G_ARRAY) { RETURNOP(((LOGOP*)cUNOP->op_first)->op_other); } else { @@ -1175,7 +1175,7 @@ PP(pp_flop) { dSP; - if (GIMME == G_ARRAY) { + if (GIMME_V == G_ARRAY) { dPOPPOPssrl; SvGETMAGIC(left); @@ -1776,7 +1776,7 @@ PP(pp_caller) cx = caller_cx(count + !!(PL_op->op_private & OPpOFFBYONE), &dbcx); if (!cx) { - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { EXTEND(SP, 1); RETPUSHUNDEF; } @@ -1788,7 +1788,7 @@ PP(pp_caller) stash_hek = SvTYPE(CopSTASH(cx->blk_oldcop)) == SVt_PVHV ? HvNAME_HEK((HV*)CopSTASH(cx->blk_oldcop)) : NULL; - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { EXTEND(SP, 1); if (!stash_hek) PUSHs(&PL_sv_undef); @@ -1390,7 +1390,7 @@ PP(pp_match) const char *truebase; /* Start of string */ REGEXP *rx = PM_GETRE(pm); bool rxtainted; - const I32 gimme = GIMME; + const I32 gimme = GIMME_V; STRLEN len; const I32 oldsave = PL_savestack_ix; I32 had_zerolen = 0; @@ -1476,7 +1476,7 @@ PP(pp_sort) AV* av = NULL; GV *gv; CV *cv = NULL; - I32 gimme = GIMME; + I32 gimme = GIMME_V; OP* const nextop = PL_op->op_next; I32 overloading = 0; bool hasargs = FALSE; @@ -1247,7 +1247,7 @@ PP(pp_sselect) } PUSHi(nfound); - if (GIMME == G_ARRAY && tbuf) { + if (GIMME_V == G_ARRAY && tbuf) { value = (NV)(timebuf.tv_sec) + (NV)(timebuf.tv_usec) / 1000000.0; mPUSHn(value); @@ -3963,7 +3963,7 @@ PP(pp_readdir) dSP; SV *sv; - const I32 gimme = GIMME; + const I32 gimme = GIMME_V; GV * const gv = MUTABLE_GV(POPs); const Direntry_t *dp; IO * const io = GvIOn(gv); @@ -3997,7 +3997,7 @@ PP(pp_readdir) nope: if (!errno) SETERRNO(EBADF,RMS_ISI); - if (GIMME == G_ARRAY) + if (GIMME_V == G_ARRAY) RETURN; else RETPUSHUNDEF; @@ -4552,7 +4552,7 @@ PP(pp_tms) (void)PerlProc_times(×buf); mPUSHn(((NV)timesbuf.tms_utime)/(NV)PL_clocktick); - if (GIMME == G_ARRAY) { + if (GIMME_V == G_ARRAY) { mPUSHn(((NV)timesbuf.tms_stime)/(NV)PL_clocktick); mPUSHn(((NV)timesbuf.tms_cutime)/(NV)PL_clocktick); mPUSHn(((NV)timesbuf.tms_cstime)/(NV)PL_clocktick); @@ -4563,7 +4563,7 @@ PP(pp_tms) dSP; mPUSHn(0.0); EXTEND(SP, 4); - if (GIMME == G_ARRAY) { + if (GIMME_V == G_ARRAY) { mPUSHn(0.0); mPUSHn(0.0); mPUSHn(0.0); @@ -4641,7 +4641,7 @@ PP(pp_gmtime) "%s(%.0" NVff ") failed", opname, when); } - if (GIMME != G_ARRAY) { /* scalar context */ + if (GIMME_V != G_ARRAY) { /* scalar context */ EXTEND(SP, 1); EXTEND_MORTAL(1); if (err == NULL) @@ -4868,7 +4868,7 @@ PP(pp_ghostent) } #endif - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { PUSHs(sv = sv_newmortal()); if (hent) { if (which == OP_GHBYNAME) { @@ -4955,7 +4955,7 @@ PP(pp_gnetent) #endif EXTEND(SP, 4); - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { PUSHs(sv = sv_newmortal()); if (nent) { if (which == OP_GNBYNAME) @@ -5019,7 +5019,7 @@ PP(pp_gprotoent) #endif EXTEND(SP, 3); - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { PUSHs(sv = sv_newmortal()); if (pent) { if (which == OP_GPBYNAME) @@ -5085,7 +5085,7 @@ PP(pp_gservent) #endif EXTEND(SP, 4); - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { PUSHs(sv = sv_newmortal()); if (sent) { if (which == OP_GSBYNAME) { @@ -5321,7 +5321,7 @@ PP(pp_gpwent) } EXTEND(SP, 10); - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { PUSHs(sv = sv_newmortal()); if (pwent) { if (which == OP_GPWNAM) @@ -5463,7 +5463,7 @@ PP(pp_ggrent) #endif EXTEND(SP, 4); - if (GIMME != G_ARRAY) { + if (GIMME_V != G_ARRAY) { SV * const sv = sv_newmortal(); PUSHs(sv); |