From 181300d4a7506f7214538178ed79b8f57a49be8a Mon Sep 17 00:00:00 2001 From: Brochen Date: Wed, 10 Dec 2014 11:19:13 +0800 Subject: [PATCH] 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' --- src/sds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sds.c b/src/sds.c index 5a3bc82b..11f560ad 100644 --- a/src/sds.c +++ b/src/sds.c @@ -570,7 +570,7 @@ sds sdstrim(sds s, const char *cset) { sp = start = s; ep = end = s+sdslen(s)-1; 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); if (sh->buf != sp) memmove(sh->buf, sp, len); sh->buf[len] = '\0';