diff options
author | David Mitchell <davem@iabyn.com> | 2012-02-27 11:32:36 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-02-27 11:32:36 +0000 |
commit | 55d3f3e53492b8cc2dcf2c5ff35f6b379b1685e8 (patch) | |
tree | 460d0755ab7dc3098c56156e675b691f5f82f147 /av.c | |
parent | a90703188215281875f4dfa669aa77828d6aa7c4 (diff) | |
download | perl-55d3f3e53492b8cc2dcf2c5ff35f6b379b1685e8.tar.gz |
av_fetch: de-duplicate small bit of code
make the code slightly smaller by changing
if (A)
return X;
if (B)
return X;
into
`
if (A || B)
return X;
Diffstat (limited to 'av.c')
-rw-r--r-- | av.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -249,18 +249,12 @@ Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval) return NULL; } - if (key > AvFILLp(av)) { - if (!lval) - return NULL; - return av_store(av,key,newSV(0)); - } - if (AvARRAY(av)[key] == &PL_sv_undef) { - emptyness: - if (lval) - return av_store(av,key,newSV(0)); - return NULL; + if (key > AvFILLp(av) || AvARRAY(av)[key] == &PL_sv_undef) { + emptyness: + return lval ? av_store(av,key,newSV(0)) : NULL; } - else if (AvREIFY(av) + + if (AvREIFY(av) && (!AvARRAY(av)[key] /* eg. @_ could have freed elts */ || SvIS_FREED(AvARRAY(av)[key]))) { AvARRAY(av)[key] = &PL_sv_undef; /* 1/2 reify */ |