Skip to content

Commit

Permalink
doop.c: do_vecget(): Add trivial case to the switch()
Browse files Browse the repository at this point in the history
We can save another conditional by adding a default: case to the switch
statement created by the previous commit.
  • Loading branch information
khwilliamson committed Aug 6, 2021
1 parent 6c4aa50 commit f77b2d0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions doop.c
Expand Up @@ -731,7 +731,7 @@ Perl_do_sprintf(pTHX_ SV *sv, SSize_t len, SV **sarg)
UV
Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
{
STRLEN srclen, avail, uoffset;
STRLEN srclen;
const I32 svpv_flags = ((PL_op->op_flags & OPf_MOD || LVRET)
? SV_UNDEF_RETURNS_NULL : 0);
unsigned char *s = (unsigned char *)
Expand Down Expand Up @@ -760,7 +760,7 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)

if (size <= 8) {
STRLEN bitoffs = ((offset % 8) * size) % 8;
uoffset = offset / (8 / size);
STRLEN uoffset = offset / (8 / size);

if (uoffset >= srclen)
return 0;
Expand All @@ -769,6 +769,7 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
}
else {
int n = size / 8; /* required number of bytes */
SSize_t uoffset;

#ifdef UV_IS_QUAD

Expand All @@ -782,12 +783,9 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)

uoffset = offset * n;

if (uoffset >= srclen)
return 0;

avail = srclen - uoffset; /* available number of bytes */

switch (MIN(n, avail)) {
/* Switch on the number of bytes available, but no more than the number
* required */
switch (MIN(n, (SSize_t) srclen - uoffset)) {

#ifdef UV_IS_QUAD

Expand Down Expand Up @@ -816,6 +814,9 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
case 1:
retnum += ((UV) s[uoffset ] << (size - 8));
break;

default:
return 0;
}
}

Expand Down

0 comments on commit f77b2d0

Please sign in to comment.