summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-03-06 15:57:21 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-03-06 19:07:32 +0100
commit84c82fbf774aa7c5e123c96735477b275c79761c (patch)
tree5dd066763c36c7103537270dfd2ae11ba3fef0c4 /pp_ctl.c
parent6e03d7438337d3d902ac13cc268ff27c33c4bbe8 (diff)
downloadperl-84c82fbf774aa7c5e123c96735477b275c79761c.tar.gz
Remove special case for coderefs with empty prototypes in smart match
(plus, fix a metasyntactic name clash in the switch test)
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c55
1 files changed, 1 insertions, 54 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index f512832a30..33ac1ee6f7 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4029,18 +4029,10 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
SV *This, *Other; /* 'This' (and Other to match) to play with C++ */
REGEXP *this_regex, *other_regex;
-# define NOT_EMPTY_PROTO(cv) (!SvPOK(cv) || SvCUR(cv) == 0)
-
# define SM_REF(type) ( \
(SvROK(d) && (SvTYPE(This = SvRV(d)) == SVt_##type) && (Other = e)) \
|| (SvROK(e) && (SvTYPE(This = SvRV(e)) == SVt_##type) && (Other = d)))
-# define SM_CV_NEP /* Find a code ref without an empty prototype */ \
- ((SvROK(d) && (SvTYPE(This = SvRV(d)) == SVt_PVCV) \
- && NOT_EMPTY_PROTO(This) && (Other = e)) \
- || (SvROK(e) && (SvTYPE(This = SvRV(e)) == SVt_PVCV) \
- && NOT_EMPTY_PROTO(This) && (Other = d)))
-
# define SM_REGEX ( \
(SvROK(d) && (SvTYPE(This = SvRV(d)) == SVt_REGEXP) \
&& (this_regex = (REGEXP*) This) \
@@ -4094,17 +4086,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
Perl_croak(aTHX_ "Smart matching a non-overloaded object breaks encapsulation");
}
- if (SM_CV_NEP) {
+ if (SM_REF(PVCV)) {
I32 c;
-
- if ( SM_OTHER_REF(PVCV) && NOT_EMPTY_PROTO(SvRV(Other)) )
- {
- if (This == SvRV(Other))
- RETPUSHYES;
- else
- RETPUSHNO;
- }
-
ENTER;
SAVETMPS;
PUSHMARK(SP);
@@ -4338,42 +4321,6 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
destroy_matcher(matcher);
RETURN;
}
- else if (SM_REF(PVCV)) {
- I32 c;
- /* This must be a null-prototyped sub, because we
- already checked for the other kind. */
-
- ENTER;
- SAVETMPS;
- PUSHMARK(SP);
- PUTBACK;
- c = call_sv(This, G_SCALAR);
- SPAGAIN;
- if (c == 0)
- PUSHs(&PL_sv_undef);
- else if (SvTEMP(TOPs))
- SvREFCNT_inc_void(TOPs);
-
- if (SM_OTHER_REF(PVCV)) {
- /* This one has to be null-proto'd too.
- Call both of 'em, and compare the results */
- PUSHMARK(SP);
- c = call_sv(SvRV(Other), G_SCALAR);
- SPAGAIN;
- if (c == 0)
- PUSHs(&PL_sv_undef);
- else if (SvTEMP(TOPs))
- SvREFCNT_inc_void(TOPs);
- FREETMPS;
- LEAVE;
- PUTBACK;
- return pp_eq();
- }
-
- FREETMPS;
- LEAVE;
- RETURN;
- }
else if ( ((SvIOK(d) || SvNOK(d)) && (This = d) && (Other = e))
|| ((SvIOK(e) || SvNOK(e)) && (This = e) && (Other = d)) )
{