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".
This commit is contained in:
antirez
2013-07-24 11:21:39 +02:00
parent 75b760a72d
commit 6ea8e0949c
5 changed files with 10 additions and 11 deletions

View File

@ -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'. */