This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove some redundant magical flag checks
authorFather Chrysostomos <sprout@cpan.org>
Sun, 29 Jul 2012 07:26:55 +0000 (00:26 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 29 Jul 2012 07:28:01 +0000 (00:28 -0700)
Now that gmagical svs use the OK flags the same way as muggles,
things like SvPOK || (SvGMAGICAL && SvPOKp) are no longer necessary.

pp.c
universal.c

diff --git a/pp.c b/pp.c
index a57f609..5a40a2d 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -2182,7 +2182,7 @@ PP(pp_negate)
     {
        SV * const sv = TOPs;
 
-       if (SvIOK(sv) || (SvGMAGICAL(sv) && SvIOKp(sv))) {
+       if (SvIOK(sv)) {
            /* It's publicly an integer */
        oops_its_an_int:
            if (SvIsUV(sv)) {
index a7c480f..cb49e0b 100644 (file)
@@ -198,8 +198,7 @@ Perl_sv_does_sv(pTHX_ SV *sv, SV *namesv, U32 flags)
 
     SvGETMAGIC(sv);
 
-    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
-           || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv)))) {
+    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)))) {
        LEAVE;
        return FALSE;
     }
@@ -334,8 +333,7 @@ XS(XS_UNIVERSAL_isa)
 
        SvGETMAGIC(sv);
 
-       if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
-                   || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
+       if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))))
            XSRETURN_UNDEF;
 
        ST(0) = boolSV(sv_derived_from_sv(sv, ST(1), 0));
@@ -359,7 +357,7 @@ XS(XS_UNIVERSAL_can)
     SvGETMAGIC(sv);
 
     if (!SvOK(sv) || !(SvROK(sv) || SvNIOK(sv) || (SvPOK(sv) && SvCUR(sv))
-       || (SvGMAGICAL(sv) && (SvNIOKp(sv) || (SvPOKp(sv) && SvCUR(sv))))))
+       ))
        XSRETURN_UNDEF;
 
     rv = &PL_sv_undef;