sds
sds copied to clipboard
sds.c:there is no need to compare the value of ep and sp
Hi, I found a small problem:
sp = start = s;
// the only way that make ep > sp is sdslen(s) == 0
// so when ep > sp,must exist ep-sp == -1
ep = end = s+sdslen(s)-1;
while(sp <= end && strchr(cset, *sp)) sp++;
while(ep > sp && strchr(cset, *ep)) ep--;
// -1 + 1 already equals 0
len = (sp > ep) ? 0 : ((ep-sp)+1);
So I think there is no need to determine the size of ep and sp, I am not really sure, is that right?
Signed-off-by: Bo Cai [email protected]