Commit c49955fd authored by antirez's avatar antirez
Browse files

Scripting: replace tolower() with faster code in evalGenericCommand().

The function showed up consuming a non trivial amount of time in the
profiler output. After this change benchmarking gives a 6% speed
improvement that can be consistently measured.
parent 0ef4f44c
...@@ -860,8 +860,12 @@ void evalGenericCommand(redisClient *c, int evalsha) { ...@@ -860,8 +860,12 @@ void evalGenericCommand(redisClient *c, int evalsha) {
int j; int j;
char *sha = c->argv[1]->ptr; char *sha = c->argv[1]->ptr;
/* Convert to lowercase. We don't use tolower since the function
* managed to always show up in the profiler output consuming
* a non trivial amount of time. */
for (j = 0; j < 40; j++) for (j = 0; j < 40; j++)
funcname[j+2] = tolower(sha[j]); funcname[j+2] = (sha[j] >= 'A' && sha[j] <= 'Z') ?
sha[j]+('a'-'A') : sha[j];
funcname[42] = '\0'; funcname[42] = '\0';
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment