summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-03-29 14:49:58 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-05-21 10:48:43 -0700
commitd2c4d2d1e22d31255e4879b333999b8d409086a2 (patch)
tree31864e4bd00c9af3824573275ac5b2c2b9c8153c /pp_sys.c
parent88187f3299a69eab9bcd24124c19b84f30796fff (diff)
downloadperl-d2c4d2d1e22d31255e4879b333999b8d409086a2.tar.gz
Make filetest ops fiddle the stack less
See commits 8db8f6b697e and d6642e439 for the background. Instead of sometimes popping items off the stack for filetest operat- ors and sometimes not, just leave the item on the stack and use SETs to return the value (which the overload code was doing already any- way). This simplifies the code and allows d6642e439 to be reverted. It also makes things theoretically faster, simply because there is less stuff happening.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 70a026b438..97537639fa 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2919,15 +2919,15 @@ S_ft_stacking_return_false(pTHX_ SV *ret) {
STMT_START { \
if (PL_op->op_private & OPpFT_STACKING) \
return S_ft_stacking_return_false(aTHX_ X); \
- RETURNX(PUSHs(X)); \
+ RETURNX(PL_op->op_flags & OPf_REF ? PUSHs(X) : SETs(X)); \
} STMT_END
#define FT_RETURN_TRUE(X) \
RETURNX((void)( \
- PL_op->op_private & OPpFT_STACKING \
- ? PL_op->op_flags & OPf_REF \
- ? PUSHs((SV *)cGVOP_gv) \
- : 0 \
- : PUSHs(X) \
+ PL_op->op_flags & OPf_REF \
+ ? PUSHs( \
+ PL_op->op_private & OPpFT_STACKING ? (SV *)cGVOP_gv : (X) \
+ ) \
+ : (void)(PL_op->op_private & OPpFT_STACKING || SETs(X)) \
))
#define FT_RETURNNO FT_RETURN_FALSE(&PL_sv_no)
@@ -2961,14 +2961,10 @@ S_try_amagic_ftest(pTHX_ char chr) {
if (!tmpsv)
return NULL;
- if (PL_op->op_private & OPpFT_STACKING) {
- if (SvTRUE(tmpsv)) return NORMAL;
- return S_ft_stacking_return_false(aTHX_ tmpsv);
- }
-
SPAGAIN;
- RETURNX(SETs(tmpsv));
+ if (SvTRUE(tmpsv)) FT_RETURN_TRUE(tmpsv);
+ FT_RETURN_FALSE(tmpsv);
}
return NULL;
}
@@ -3061,7 +3057,7 @@ PP(pp_ftrread)
if (use_access) {
#if defined(HAS_ACCESS) || defined (PERL_EFF_ACCESS)
- const char *name = POPpx;
+ const char *name = TOPpx;
if (effective) {
# ifdef PERL_EFF_ACCESS
result = PERL_EFF_ACCESS(name, access_mode);
@@ -3078,10 +3074,10 @@ PP(pp_ftrread)
# endif
}
if (result == 0)
- RETPUSHYES;
+ FT_RETURNYES;
if (result < 0)
- RETPUSHUNDEF;
- RETPUSHNO;
+ FT_RETURNUNDEF;
+ FT_RETURNNO;
#endif
}
@@ -3175,22 +3171,16 @@ PP(pp_ftrowned)
system these days. */
#ifndef S_ISUID
if(PL_op->op_type == OP_FTSUID) {
- if ((PL_op->op_flags & OPf_REF) == 0 && !(PL_op->op_private & OPpFT_STACKING))
- (void) POPs;
FT_RETURNNO;
}
#endif
#ifndef S_ISGID
if(PL_op->op_type == OP_FTSGID) {
- if ((PL_op->op_flags & OPf_REF) == 0 && !(PL_op->op_private & OPpFT_STACKING))
- (void) POPs;
FT_RETURNNO;
}
#endif
#ifndef S_ISVTX
if(PL_op->op_type == OP_FTSVTX) {
- if ((PL_op->op_flags & OPf_REF) == 0 && !(PL_op->op_private & OPpFT_STACKING))
- (void) POPs;
FT_RETURNNO;
}
#endif
@@ -3289,7 +3279,7 @@ PP(pp_fttty)
if (PL_op->op_flags & OPf_REF)
gv = cGVOP_gv;
else {
- SV *tmpsv = PL_op->op_private & OPpFT_STACKING ? TOPs : POPs;
+ SV *tmpsv = TOPs;
if (!(gv = MAYBE_DEREF_GV_nomg(tmpsv))) {
name = SvPV_nomg(tmpsv, namelen);
gv = gv_fetchpvn_flags(name, namelen, SvUTF8(tmpsv), SVt_PVIO);
@@ -3336,12 +3326,12 @@ PP(pp_fttext)
gv = cGVOP_gv;
EXTEND(SP, 1);
}
- else {
- sv = PL_op->op_private & OPpFT_STACKING ? TOPs : POPs;
- if ((PL_op->op_private & (OPpFT_STACKED|OPpFT_AFTER_t))
+ else if ((PL_op->op_private & (OPpFT_STACKED|OPpFT_AFTER_t))
== OPpFT_STACKED)
gv = PL_defgv;
- else gv = MAYBE_DEREF_GV_nomg(sv);
+ else {
+ sv = TOPs;
+ gv = MAYBE_DEREF_GV_nomg(sv);
}
if (gv) {