mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
FS-4928 doing 100 calls I found 7 million calls to toupper, this patch replaces it with an inline optimized one I found online. Not sure it helps but maybe you can profile it again with latest.
This commit is contained in:
@@ -40,7 +40,18 @@
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C SWITCH_DECLARE(int) switch_toupper(int c);
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii */
|
||||
static inline uint32_t switch_toupper(uint32_t eax)
|
||||
{
|
||||
uint32_t ebx = (0x7f7f7f7ful & eax) + 0x05050505ul;
|
||||
ebx = (0x7f7f7f7ful & ebx) + 0x1a1a1a1aul;
|
||||
ebx = ((ebx & ~eax) >> 2 ) & 0x20202020ul;
|
||||
return eax - ebx;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) old_switch_toupper(int c);
|
||||
SWITCH_DECLARE(int) switch_tolower(int c);
|
||||
SWITCH_DECLARE(int) switch_isalnum(int c);
|
||||
SWITCH_DECLARE(int) switch_isalpha(int c);
|
||||
|
Reference in New Issue
Block a user