From: Bruno Haible Date: Fri, 2 Apr 2021 17:50:19 +0000 (+0200) Subject: strtol, strtoul, strtoll, strtoull: Optimize. X-Git-Tag: v1.0~2993 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=022521230ffa940a5428ee2a50120dc882920b16;p=gnulib.git strtol, strtoul, strtoll, strtoull: Optimize. * lib/strtol.c (GROUP_PARAM_PROTO): New macro. (INTERNAL): Define differently if !USE_NUMBER_GROUPING. (INTERNAL (strtol)): Define without 'int group' parameter if !USE_NUMBER_GROUPING. (strtol): Don't define if !USE_NUMBER_GROUPING. --- diff --git a/ChangeLog b/ChangeLog index 0bf4c58da3..d5b833ae3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2021-04-02 Bruno Haible + + strtol, strtoul, strtoll, strtoull: Optimize. + * lib/strtol.c (GROUP_PARAM_PROTO): New macro. + (INTERNAL): Define differently if !USE_NUMBER_GROUPING. + (INTERNAL (strtol)): Define without 'int group' parameter if + !USE_NUMBER_GROUPING. + (strtol): Don't define if !USE_NUMBER_GROUPING. + 2021-04-02 Bruno Haible strto*l: Don't pass invalid arguments to isspace, isalnum, toupper. diff --git a/lib/strtol.c b/lib/strtol.c index 14836d04d9..c30e5b45e9 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -131,6 +131,12 @@ #endif +#ifdef USE_NUMBER_GROUPING +# define GROUP_PARAM_PROTO , int group +#else +# define GROUP_PARAM_PROTO +#endif + /* We use this code also for the extended locale handling where the function gets as an additional argument the locale which has to be used. To access the values we have to redefine the _NL_CURRENT @@ -176,9 +182,13 @@ # endif #endif -#define INTERNAL(X) INTERNAL1(X) -#define INTERNAL1(X) __##X##_internal -#define WEAKNAME(X) WEAKNAME1(X) +#ifdef USE_NUMBER_GROUPING +# define INTERNAL(X) INTERNAL1(X) +# define INTERNAL1(X) __##X##_internal +# define WEAKNAME(X) WEAKNAME1(X) +#else +# define INTERNAL(X) X +#endif #ifdef USE_NUMBER_GROUPING /* This file defines a function to check for correct grouping. */ @@ -196,7 +206,7 @@ INT INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, - int base, int group LOCALE_PARAM_PROTO) + int base GROUP_PARAM_PROTO LOCALE_PARAM_PROTO) { int negative; register unsigned LONG int cutoff; @@ -379,15 +389,16 @@ noconv: return 0L; } +#ifdef USE_NUMBER_GROUPING /* External user entry point. */ - INT -#ifdef weak_function +# ifdef weak_function weak_function -#endif +# endif strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base LOCALE_PARAM_PROTO) { return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); } +#endif