summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-07-23 22:32:45 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-07-24 09:08:14 -0400
commit945b524a8cdacbf82557d751252e6546f48d21ae (patch)
treeb61bf5ee596aff9d50b82b8415a2bc6bf532f475 /numeric.c
parent75feedba47600d94d18d49dbcbdf46393b6c6cc5 (diff)
downloadperl-945b524a8cdacbf82557d751252e6546f48d21ae.tar.gz
Share common constants as file statics.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/numeric.c b/numeric.c
index d3eaa60f25..a203bf5c75 100644
--- a/numeric.c
+++ b/numeric.c
@@ -586,13 +586,14 @@ Perl_grok_number(pTHX_ const char *pv, STRLEN len, UV *valuep)
return grok_number_flags(pv, len, valuep, 0);
}
+static const UV uv_max_div_10 = UV_MAX / 10;
+static const U8 uv_max_mod_10 = UV_MAX % 10;
+
int
Perl_grok_number_flags(pTHX_ const char *pv, STRLEN len, UV *valuep, U32 flags)
{
const char *s = pv;
const char * const send = pv + len;
- const UV max_div_10 = UV_MAX / 10;
- const char max_mod_10 = UV_MAX % 10;
int numtype = 0;
int sawinf = 0;
int sawnan = 0;
@@ -660,9 +661,9 @@ Perl_grok_number_flags(pTHX_ const char *pv, STRLEN len, UV *valuep, U32 flags)
each time for overflow. */
digit = *s - '0';
while (digit >= 0 && digit <= 9
- && (value < max_div_10
- || (value == max_div_10
- && digit <= max_mod_10))) {
+ && (value < uv_max_div_10
+ || (value == uv_max_div_10
+ && digit <= uv_max_mod_10))) {
value = value * 10 + digit;
if (++s < send)
digit = *s - '0';
@@ -832,8 +833,6 @@ Perl_grok_atou(const char *pv, const char** endptr)
const char** eptr;
const char* end2; /* Used in case endptr is NULL. */
UV val = 0; /* The return value. */
- const UV max_div_10 = UV_MAX / 10;
- const UV max_mod_10 = UV_MAX % 10;
PERL_ARGS_ASSERT_GROK_ATOU;
@@ -852,8 +851,8 @@ Perl_grok_atou(const char *pv, const char** endptr)
* the expected uses of this are not speed-needy, and
* unlikely to need full 64-bitness. */
U8 digit = *s++ - '0';
- if (val < max_div_10 ||
- (val == max_div_10 && digit <= max_mod_10)) {
+ if (val < uv_max_div_10 ||
+ (val == uv_max_div_10 && digit <= uv_max_mod_10)) {
val = val * 10 + digit;
} else {
*eptr = NULL;