summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2012-02-27 11:32:36 +0000
committerDavid Mitchell <davem@iabyn.com>2012-02-27 11:32:36 +0000
commit55d3f3e53492b8cc2dcf2c5ff35f6b379b1685e8 (patch)
tree460d0755ab7dc3098c56156e675b691f5f82f147
parenta90703188215281875f4dfa669aa77828d6aa7c4 (diff)
downloadperl-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;
-rw-r--r--av.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/av.c b/av.c
index 1114531bd9..aada6c6b17 100644
--- a/av.c
+++ b/av.c
@@ -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 */