rockbox/firmware/libc/include
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
..
sys Move include/sys along with libc/, so hosted (sim/RaaA) builds use the proper files for their OS 2010-05-14 22:01:07 +00:00
ctype.h isdigit replace with a slightly faster and shorter conditional 2025-02-02 13:57:58 -05:00
endian.h Do a better endian.h setup that isn't as fragile 2014-08-25 12:16:56 -04:00
errno.h Rewrite filesystem code (WIP) 2014-08-30 03:48:23 +02:00
fcntl.h Rewrite filesystem code (WIP) 2014-08-30 03:48:23 +02:00
inttypes.h inttypes.h: remove excessive PRI*PTR declaration when long isn't 64 bits 2010-05-30 16:07:54 +00:00
math.h Move math.h to firmware/libc/include/ and fix slight incompatibilities between our and the host's math.h 2010-05-14 12:43:45 +00:00
stdint.h libc: We need to define SIZE_MAX in our stdint.h 2024-12-30 15:22:11 -05:00
stdio.h Move some gcc extensions to new gcc_extensions.h header 2010-07-25 14:44:29 +00:00
stdlib.h libc: Correct definition of labs()' and add llabs() 2024-10-12 12:01:36 -04:00
string.h strlcpy finish cleanup 2022-11-17 01:54:46 -05:00
time.h file/fat: rework utime function as modtime extension 2021-07-08 17:47:51 +00:00