Skip to content

Commit d31998e

Browse files
committed
Nest conditions for checking negative keys
1 parent eb443c9 commit d31998e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

av.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,12 @@ Perl_av_fetch(pTHX_ AV *av, SSize_t key, I32 lval)
293293
/* the cast from SSize_t to Size_t allows both (key < 0) and (key >= size)
294294
* to be tested as a single condition */
295295
if ((Size_t)key >= (Size_t)size) {
296-
if (LIKELY(key < 0))
296+
if (LIKELY(key < 0)) {
297297
key += size;
298-
else
298+
if (UNLIKELY(key < 0))
299+
return NULL;
300+
} else
299301
goto emptiness;
300-
301-
if (UNLIKELY(key < 0))
302-
return NULL;
303302
}
304303

305304
if (AvARRAY(av)[key])

0 commit comments

Comments
 (0)