From f85b645f3c47de3813732fdb9510ff559350c7ee Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 27 Mar 2019 21:19:04 -0600 Subject: [PATCH] numeric.c: use new inRANGE macro This commit halves the number of conditionals needed in this hot code. --- numeric.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/numeric.c b/numeric.c index 9804a9b3416b..710653053f1f 100644 --- a/numeric.c +++ b/numeric.c @@ -899,41 +899,41 @@ Perl_grok_number_flags(pTHX_ const char *pv, STRLEN len, UV *valuep, U32 flags) before checking for overflow. */ if (++s < send) { int digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; - if (digit >= 0 && digit <= 9) { + if (inRANGE(digit, 0, 9)) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; - while (digit >= 0 && digit <= 9 + while ( inRANGE(digit, 0, 9) && (value < uv_max_div_10 || (value == uv_max_div_10 && digit <= uv_max_mod_10))) { @@ -943,7 +943,7 @@ Perl_grok_number_flags(pTHX_ const char *pv, STRLEN len, UV *valuep, U32 flags) else break; } - if (digit >= 0 && digit <= 9 + if (inRANGE(digit, 0, 9) && (s < send)) { /* value overflowed. skip the remaining digits, don't