diff options
author | Matt Stancliff <matt@genges.com> | 2014-08-07 09:43:16 -0400 |
---|---|---|
committer | Matt Stancliff <matt@genges.com> | 2014-12-11 10:54:21 -0500 |
commit | badf0f008bede268d3235412243fc62d618e323c (patch) | |
tree | 260e8c610405b57e79d81757f24107e169c4b72f /src/t_string.c | |
parent | 3cd36a4dd9b31b351c87f1084bc6166a44044315 (diff) | |
download | redis-badf0f008bede268d3235412243fc62d618e323c.tar.gz |
Bitops: Stop overallocating storage space on set
Previously the string was created empty then re-sized
to fit the offset, but sds resize causes the sds to
over-allocate by at least 1 MB (which is a lot when
you are operating at bit-level access).
This also improves the speed of initial sets by 2% to 6%
based on quick testing.
Patch logic provided by @oranagra
Fixes #1918
Diffstat (limited to 'src/t_string.c')
-rw-r--r-- | src/t_string.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_string.c b/src/t_string.c index e3c1e5f4a..b61589961 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -194,7 +194,7 @@ void setrangeCommand(redisClient *c) { if (checkStringLength(c,offset+sdslen(value)) != REDIS_OK) return; - o = createObject(REDIS_STRING,sdsempty()); + o = createObject(REDIS_STRING,sdsnewlen(NULL, offset+sdslen(value))); dbAdd(c->db,c->argv[1],o); } else { size_t olen; |