summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-07-24 11:21:39 +0200
committerantirez <antirez@gmail.com>2013-07-24 11:22:52 +0200
commitf899ab55ca2862246eb0d76bb1f1f0616bb0190e (patch)
tree80c6cf181d168b113b2111c029c6e55ad947a2b5
parenta1d37ba46971ed953a0b89148c45d4d1cbe52ca3 (diff)
downloadredis-f899ab55ca2862246eb0d76bb1f1f0616bb0190e.tar.gz
sdsrange() does not need to return a value.
Actaully the string is modified in-place and a reallocation is never needed, so there is no need to return the new sds string pointer as return value of the function, that is now just "void".
-rw-r--r--src/networking.c10
-rw-r--r--src/sds.c5
-rw-r--r--src/sds.h2
-rw-r--r--src/sentinel.c2
4 files changed, 9 insertions, 10 deletions
diff --git a/src/networking.c b/src/networking.c
index 992de156b..22b7dd8e7 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -848,7 +848,7 @@ int processInlineBuffer(redisClient *c) {
sdsfree(aux);
/* Leave data after the first line of the query in the buffer */
- c->querybuf = sdsrange(c->querybuf,querylen+2,-1);
+ sdsrange(c->querybuf,querylen+2,-1);
/* Setup argv array on client structure */
if (c->argv) zfree(c->argv);
@@ -877,7 +877,7 @@ static void setProtocolError(redisClient *c, int pos) {
sdsfree(client);
}
c->flags |= REDIS_CLOSE_AFTER_REPLY;
- c->querybuf = sdsrange(c->querybuf,pos,-1);
+ sdsrange(c->querybuf,pos,-1);
}
int processMultibulkBuffer(redisClient *c) {
@@ -915,7 +915,7 @@ int processMultibulkBuffer(redisClient *c) {
pos = (newline-c->querybuf)+2;
if (ll <= 0) {
- c->querybuf = sdsrange(c->querybuf,pos,-1);
+ sdsrange(c->querybuf,pos,-1);
return REDIS_OK;
}
@@ -964,7 +964,7 @@ int processMultibulkBuffer(redisClient *c) {
* try to make it likely that it will start at c->querybuf
* boundary so that we can optimized object creation
* avoiding a large copy of data. */
- c->querybuf = sdsrange(c->querybuf,pos,-1);
+ sdsrange(c->querybuf,pos,-1);
pos = 0;
/* Hint the sds library about the amount of bytes this string is
* going to contain. */
@@ -1003,7 +1003,7 @@ int processMultibulkBuffer(redisClient *c) {
}
/* Trim to pos */
- if (pos) c->querybuf = sdsrange(c->querybuf,pos,-1);
+ if (pos) sdsrange(c->querybuf,pos,-1);
/* We're done when c->multibulk == 0 */
if (c->multibulklen == 0) return REDIS_OK;
diff --git a/src/sds.c b/src/sds.c
index b63f44d94..d66c1d730 100644
--- a/src/sds.c
+++ b/src/sds.c
@@ -385,11 +385,11 @@ sds sdstrim(sds s, const char *cset) {
* s = sdsnew("Hello World");
* sdstrim(s,1,-1); => "ello Worl"
*/
-sds sdsrange(sds s, int start, int end) {
+void sdsrange(sds s, int start, int end) {
struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
size_t newlen, len = sdslen(s);
- if (len == 0) return s;
+ if (len == 0) return;
if (start < 0) {
start = len+start;
if (start < 0) start = 0;
@@ -413,7 +413,6 @@ sds sdsrange(sds s, int start, int end) {
sh->buf[newlen] = 0;
sh->free = sh->free+(sh->len-newlen);
sh->len = newlen;
- return s;
}
/* Apply tolower() to every character of the sds string 's'. */
diff --git a/src/sds.h b/src/sds.h
index 46d914fd1..6f3201130 100644
--- a/src/sds.h
+++ b/src/sds.h
@@ -77,7 +77,7 @@ sds sdscatprintf(sds s, const char *fmt, ...);
#endif
sds sdstrim(sds s, const char *cset);
-sds sdsrange(sds s, int start, int end);
+void sdsrange(sds s, int start, int end);
void sdsupdatelen(sds s);
void sdsclear(sds s);
int sdscmp(const sds s1, const sds s2);
diff --git a/src/sentinel.c b/src/sentinel.c
index 659de29b8..b257ad685 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -1920,7 +1920,7 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
if (ri->flags & SRI_RECONF_DONE) flags = sdscat(flags,"reconf_done,");
if (ri->flags & SRI_DEMOTE) flags = sdscat(flags,"demote,");
- if (sdslen(flags) != 0) flags = sdsrange(flags,0,-2); /* remove last "," */
+ if (sdslen(flags) != 0) sdsrange(flags,0,-2); /* remove last "," */
addReplyBulkCString(c,flags);
sdsfree(flags);
fields++;