summaryrefslogtreecommitdiff
path: root/pp.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2014-03-12 19:14:13 +0000
committerDavid Mitchell <davem@iabyn.com>2014-03-12 20:19:03 +0000
commit5d9574c10ca04dcefc1cac5441cb321f7bb4cc37 (patch)
tree66acefea54382fa30b9c1c2b73c99d578f65c027 /pp.h
parent85c8e3067c12431ded3d5289a8ec16cf2e33ebaf (diff)
downloadperl-5d9574c10ca04dcefc1cac5441cb321f7bb4cc37.tar.gz
sprinkle LIKELY() on pp_hot.c scope.c and some *.h
I've gone through pp_hot.c and scope.c and added LIKELY() or UNLIKELY() to all conditionals where I understand the code well enough to know that a particular branch is or isn't likely to be taken very often. I also processed some of the .h files which contain commonly used macros.
Diffstat (limited to 'pp.h')
-rw-r--r--pp.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/pp.h b/pp.h
index d0a62fb5b1..97738c2d8d 100644
--- a/pp.h
+++ b/pp.h
@@ -57,7 +57,7 @@ Refetch the stack pointer. Used after a callback. See L<perlcall>.
#define PUSHMARK(p) \
STMT_START { \
- if (++PL_markstack_ptr == PL_markstack_max) \
+ if (UNLIKELY(++PL_markstack_ptr == PL_markstack_max)) \
markstack_grow(); \
*PL_markstack_ptr = (I32)((p) - PL_stack_base);\
} STMT_END
@@ -400,12 +400,12 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
/* do SvGETMAGIC on the stack args before checking for overload */
#define tryAMAGICun_MG(method, flags) STMT_START { \
- if ( (SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG)) \
+ if ( UNLIKELY((SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG))) \
&& Perl_try_amagic_un(aTHX_ method, flags)) \
return NORMAL; \
} STMT_END
#define tryAMAGICbin_MG(method, flags) STMT_START { \
- if ( ((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG)) \
+ if ( UNLIKELY(((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG))) \
&& Perl_try_amagic_bin(aTHX_ method, flags)) \
return NORMAL; \
} STMT_END
@@ -422,10 +422,11 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
SV *tmpsv; \
SV *arg= *sp; \
int gimme = GIMME_V; \
- if (SvAMAGIC(arg) && \
+ if (UNLIKELY(SvAMAGIC(arg) && \
(tmpsv = amagic_call(arg, &PL_sv_undef, meth, \
AMGf_want_list | AMGf_noright \
- |AMGf_unary))) { \
+ |AMGf_unary)))) \
+ { \
SPAGAIN; \
if (gimme == G_VOID) { \
(void)POPs; /* XXX ??? */ \