mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Update sds.c
in the case (all chars of the string s found in 'cset' ), line[573] will no more do the same thing line[572] did. this will be more faster especially in the case that the string s is very long and all chars of string s found in 'cset'
This commit is contained in:
parent
d2aa91ce1f
commit
181300d4a7
@ -570,7 +570,7 @@ sds sdstrim(sds s, const char *cset) {
|
|||||||
sp = start = s;
|
sp = start = s;
|
||||||
ep = end = s+sdslen(s)-1;
|
ep = end = s+sdslen(s)-1;
|
||||||
while(sp <= end && strchr(cset, *sp)) sp++;
|
while(sp <= end && strchr(cset, *sp)) sp++;
|
||||||
while(ep > start && strchr(cset, *ep)) ep--;
|
while(ep > sp && strchr(cset, *ep)) ep--;
|
||||||
len = (sp > ep) ? 0 : ((ep-sp)+1);
|
len = (sp > ep) ? 0 : ((ep-sp)+1);
|
||||||
if (sh->buf != sp) memmove(sh->buf, sp, len);
|
if (sh->buf != sp) memmove(sh->buf, sp, len);
|
||||||
sh->buf[len] = '\0';
|
sh->buf[len] = '\0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user