From 08ea98c9e9f32288d21a0caf8362342f500dcc21 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 6 May 2014 10:19:51 +0200 Subject: 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. --- src/scripting.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scripting.c b/src/scripting.c index e28662db1..8eddb2a5e 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -861,8 +861,12 @@ void evalGenericCommand(redisClient *c, int evalsha) { int j; 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++) - funcname[j+2] = tolower(sha[j]); + funcname[j+2] = (sha[j] >= 'A' && sha[j] <= 'Z') ? + sha[j]+('a'-'A') : sha[j]; funcname[42] = '\0'; } -- cgit v1.2.1