This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
av_fetch(): remove redundant condition
authorDavid Mitchell <davem@iabyn.com>
Wed, 17 Aug 2016 08:01:44 +0000 (09:01 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 17 Aug 2016 08:01:44 +0000 (09:01 +0100)
At the point of testing for !AvARRAY(av)[key] if AvREIFY(av), it's already
been confirmed that the array element isn't null.

av.c

diff --git a/av.c b/av.c
index fc2004e..2f81971 100644 (file)
--- a/av.c
+++ b/av.c
@@ -279,9 +279,8 @@ Perl_av_fetch(pTHX_ AV *av, SSize_t key, I32 lval)
        return lval ? av_store(av,key,newSV(0)) : NULL;
     }
 
-    if (AvREIFY(av)
-            && (!AvARRAY(av)[key]      /* eg. @_ could have freed elts */
-                || SvIS_FREED(AvARRAY(av)[key]))) {
+    if (AvREIFY(av) && SvIS_FREED(AvARRAY(av)[key])) {
+       /* eg. @_ could have freed elts */
        AvARRAY(av)[key] = NULL;        /* 1/2 reify */
        goto emptyness;
     }