Skip to content

Commit c49955f

Browse files
committed
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.
1 parent 0ef4f44 commit c49955f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/scripting.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,12 @@ void evalGenericCommand(redisClient *c, int evalsha) {
860860
int j;
861861
char *sha = c->argv[1]->ptr;
862862

863+
/* Convert to lowercase. We don't use tolower since the function
864+
* managed to always show up in the profiler output consuming
865+
* a non trivial amount of time. */
863866
for (j = 0; j < 40; j++)
864-
funcname[j+2] = tolower(sha[j]);
867+
funcname[j+2] = (sha[j] >= 'A' && sha[j] <= 'Z') ?
868+
sha[j]+('a'-'A') : sha[j];
865869
funcname[42] = '\0';
866870
}
867871

0 commit comments

Comments
 (0)