From 40f7035ba47c3cdf161e3801d89fcc8afbd0c458 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Fri, 1 Aug 2014 16:18:36 -0700 Subject: 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 --- sds.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sds.h') diff --git a/sds.h b/sds.h index ab6fc9c..26f84e3 100644 --- a/sds.h +++ b/sds.h @@ -76,6 +76,7 @@ sds sdscatprintf(sds s, const char *fmt, ...) sds sdscatprintf(sds s, const char *fmt, ...); #endif +sds sdscatfmt(sds s, char const *fmt, ...); void sdstrim(sds s, const char *cset); void sdsrange(sds s, int start, int end); void sdsupdatelen(sds s); -- cgit v1.2.3