rockbox/firmware/libc
William Wilgus 231d552972 isdigit replace with a slightly faster and shorter conditional
in testing of three ways of doing this
current: ((_ctype_+1)[(unsigned char)(c)]&_N)

alt1(this patch): (((unsigned int) (c) - '0') < 10)

alt2: ((unsigned int)(c ^ 0x30) < 10)

alt1 and alt2 are the same in terms of speed and instructions (on arm v7) but alt2 has one more
instruction on mips

(across several archs in godbolt mips, armv7v8, x86) and on ARM7 (clipzip) device about 9% faster

less false positives for both alt1 and 2 when you start supplying more than 8bits
not sure if that matters in practice though

I tried similar with isxdigit but could only get to within 1 instruction of the ctype implementation
although it negated the array lookup I saw no discernable speed difference on device

https://godbolt.org/z/qGvh4hqnG

Change-Id: I5c9e8fd3915709853e0e33427038e20a068058b6
2025-02-02 13:57:58 -05:00
..
include isdigit replace with a slightly faster and shorter conditional 2025-02-02 13:57:58 -05:00
atoi.c libc: atoi() is supposed to return 0 if handed a NULL pointer 2021-07-30 01:41:13 +00:00
ctype.c Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes). 2010-05-06 21:04:40 +00:00
errno.c Base scheduler queues off linked lists and do cleanup/consolidation 2014-08-16 05:15:37 -04:00
gmtime.c Improve code for gmtime_r() 2017-02-03 14:40:55 -05:00
memccpy.c add memccpy.c 2022-11-15 00:56:01 -04:00
memchr.c Renamed defines UNALIGNED to ROCKBOX_UNALIGNED - UNALIGNED is already 2017-01-15 21:32:49 +01:00
memcmp.c Renamed defines UNALIGNED to ROCKBOX_UNALIGNED - UNALIGNED is already 2017-01-15 21:32:49 +01:00
mktime.c mktime(): Remove redundant assignment of 'result' 2015-01-04 17:37:35 +01:00
qsort.c Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes). 2010-05-06 21:04:40 +00:00
random.c Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes). 2010-05-06 21:04:40 +00:00
sprintf.c Implement a much more capable vuprintf() 2017-11-21 05:00:27 -05:00
sscanf.c Fix reds, inclusion of C files into plugins is tricky. 2010-12-02 21:29:05 +00:00
strcat.c Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes). 2010-05-06 21:04:40 +00:00
strchr.c Renamed defines UNALIGNED to ROCKBOX_UNALIGNED - UNALIGNED is already 2017-01-15 21:32:49 +01:00
strcmp.c Renamed defines UNALIGNED to ROCKBOX_UNALIGNED - UNALIGNED is already 2017-01-15 21:32:49 +01:00
strcpy.c Renamed defines UNALIGNED to ROCKBOX_UNALIGNED - UNALIGNED is already 2017-01-15 21:32:49 +01:00
strcspn.c fix strptokspn, add strcspn, fix splash.c 2022-11-13 01:14:49 -05:00
strncmp.c Renamed defines UNALIGNED to ROCKBOX_UNALIGNED - UNALIGNED is already 2017-01-15 21:32:49 +01:00
strrchr.c Add an advanced build option to force compiling and linking our reduced C library (probably useful for the sim). 2010-06-22 18:34:03 +00:00
strstr.c strstr(): cosmetics 2010-07-11 22:37:31 +00:00