add inline isspace in ctype.h as an optimization
isspace can be a bottleneck in a simple parser, inlining it gives slightly smaller and faster code src/locale/pleval.o already had this optimization, the size change for other libc functions for i386 is src/internal/intscan.o 2134 2118 -16 src/locale/dcngettext.o 1562 1552 -10 src/network/res_msend.o 1961 1940 -21 src/network/lookup_name.o 2627 2608 -19 src/network/getnameinfo.o 1814 1811 -3 src/network/lookup_serv.o 643 624 -19 src/stdio/vfscanf.o 2675 2663 -12 src/stdlib/atoll.o 117 107 -10 src/stdlib/atoi.o 95 91 -4 src/stdlib/atol.o 95 91 -4 src/time/strptime.o 1515 1503 -12 (TOTALS) 432451 432321 -130
This commit is contained in:
parent
4fe57cad70
commit
b04971d91a
3 changed files with 7 additions and 9 deletions
|
|
@ -22,13 +22,18 @@ int isxdigit(int);
|
||||||
int tolower(int);
|
int tolower(int);
|
||||||
int toupper(int);
|
int toupper(int);
|
||||||
|
|
||||||
|
static __inline int __isspace(int _c)
|
||||||
|
{
|
||||||
|
return _c == ' ' || (unsigned)_c-'\t' < 5;
|
||||||
|
}
|
||||||
|
|
||||||
#define isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
|
#define isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
|
||||||
#define isdigit(a) (((unsigned)(a)-'0') < 10)
|
#define isdigit(a) (((unsigned)(a)-'0') < 10)
|
||||||
#define islower(a) (((unsigned)(a)-'a') < 26)
|
#define islower(a) (((unsigned)(a)-'a') < 26)
|
||||||
#define isupper(a) (((unsigned)(a)-'A') < 26)
|
#define isupper(a) (((unsigned)(a)-'A') < 26)
|
||||||
#define isprint(a) (((unsigned)(a)-0x20) < 0x5f)
|
#define isprint(a) (((unsigned)(a)-0x20) < 0x5f)
|
||||||
#define isgraph(a) (((unsigned)(a)-0x21) < 0x5e)
|
#define isgraph(a) (((unsigned)(a)-0x21) < 0x5e)
|
||||||
|
#define isspace(a) __isspace(a)
|
||||||
|
|
||||||
|
|
||||||
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
|
#undef isspace
|
||||||
|
|
||||||
int isspace(int c)
|
int isspace(int c)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,6 @@ struct st {
|
||||||
int op;
|
int op;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO: this should go into ctypes.h */
|
|
||||||
#undef isspace
|
|
||||||
#define isspace(a) __isspace(a)
|
|
||||||
static __inline int __isspace(int _c)
|
|
||||||
{
|
|
||||||
return _c == ' ' || (unsigned)_c-'\t' < 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *skipspace(const char *s)
|
static const char *skipspace(const char *s)
|
||||||
{
|
{
|
||||||
while (isspace(*s)) s++;
|
while (isspace(*s)) s++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue