2.6.19: slight performance optimization for lib/string.c's strstrip()
Quoted 17 lines
How about this:
char *strstrip(char *s)
{ size_t less = 0; char c = 0; char *e = NULL; while ((c=*s) && isspace(c)) s++; if (!c) return s; e = s; while (c=*e) {
Quoted 9 lines
less = isspace(c) ? (less + 1) : 0;
e++;
}
*(e-less) = 0;
return s;
}Well, this is not very efficient because it ends up calling isspace() function for all characters. So, Ulrich's algo is the fastest.
-Amit
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited