sds icon indicating copy to clipboard operation
sds copied to clipboard

sds.c:there is no need to compare the value of ep and sp

Open charpty opened this issue 8 years ago • 0 comments

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]

charpty avatar Jun 10 '17 14:06 charpty