summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-05-06 10:19:51 +0200
committerantirez <antirez@gmail.com>2014-05-07 16:12:32 +0200
commitc49955fd77e037cf2343bb664afe2332c6f5713e (patch)
treed30f0a100974ffb10d3a808fa7563338e0e036ff
parent0ef4f44c5a6b8d8900444c852baff223c647d5cb (diff)
downloadredis-c49955fd77e037cf2343bb664afe2332c6f5713e.tar.gz
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.
-rw-r--r--src/scripting.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/scripting.c b/src/scripting.c
index bd42f5369..479381efc 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -860,8 +860,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';
}