summaryrefslogtreecommitdiff
path: root/hiredis.h
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2014-08-01 16:18:36 -0700
committerMatt Stancliff <matt@genges.com>2015-01-05 11:21:38 -0500
commit40f7035ba47c3cdf161e3801d89fcc8afbd0c458 (patch)
treebbff5a29cf1f73f3b1581bfdba82301078320b81 /hiredis.h
parent3315c098394252cbbe00c0a69ea159f345f4f8b1 (diff)
Improve redisAppendCommandArgv performance
OK, perhaps the second time is a charm. I forgot that I had hiredis forked from a long time ago, so the initial pull request was hosed. :) * Pulled in sdscatfmt() from Redis, and modified it to accept a size_t (%T) style format specifier. * Pulled in sdsll2str() and sdsull2str() from Redis (needed by sdscatfmt). * Added a new method, redisFormatSdsCommandArgv() which takes and sds* as the target, rather than char* (and uses sdscatfmt instead of sprintf for the construction). I get roughly the following improvement: Old: 1.044806 New: 0.481620 The benchmark code itself can be found here: https://gist.github.com/michael-grunder/c92ef31bb632b3d0ad81 Closes #260
Diffstat (limited to 'hiredis.h')
-rw-r--r--hiredis.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/hiredis.h b/hiredis.h
index 7700f4b..fa3a89d 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -34,6 +34,7 @@
#include <stdio.h> /* for size_t */
#include <stdarg.h> /* for va_list */
#include <sys/time.h> /* for struct timeval */
+#include "sds.h" /* for sds */
#define HIREDIS_MAJOR 0
#define HIREDIS_MINOR 11
@@ -161,6 +162,7 @@ void freeReplyObject(void *reply);
int redisvFormatCommand(char **target, const char *format, va_list ap);
int redisFormatCommand(char **target, const char *format, ...);
int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen);
+int redisFormatSdsCommandArgv(sds *target, int argc, const char ** argv, const size_t *argvlen);
/* Context for a connection to Redis */
typedef struct redisContext {