Re: Comment on trim string function please
- From: "Bill Reid" <hormelfree@xxxxxxxxxxxxxxxx>
- Date: Sat, 12 Jul 2008 14:50:17 GMT
Willem <willem@xxxxxxxx> wrote in message
news:slrng7e79s.2a5v.willem@xxxxxxxxxxxxxxxxx
Bill Reid wrote:
) (I turn them ALL off, which means sub-scripting is not converted
) to pointers, which I believe takes longer, so to retain the speed
) I've manually converted most of the stuff like this).
As far as I know, there is no speed difference between sub-scripting
and pointers on most modern CPUs.
DAMN!!! More time I've wasted because I JUST WON'T LISTEN!!!
In any event, does the following win the prize for most efficient
implementation of the presumed requirements of the function?
char *remove_beg_end_non_text(char *text) {
char *beg;
size_t length;
for(beg=text;*beg!='\0';beg++)
if(!isspace(*beg)) break;
length=strlen(beg);
while(length>0)
if(!isspace(*(beg+(--length)))) break;
*(beg+(++length))='\0';
return beg==text ? text : memmove(text,beg,length+1);
}
Gotta admit, you couldn't reduce the cycles too much on
that, could you? And it could even win a little bonus prize
for obfuscatory conditions like if(!isspace(*(beg+(--length))))...
---
William Ernest Reid
.
- Follow-Ups:
- Re: Comment on trim string function please
- From: Ben Bacarisse
- Re: Comment on trim string function please
- References:
- Comment on trim string function please
- From: swengineer001@xxxxxxxxx
- Re: Comment on trim string function please
- From: Jens Thoms Toerring
- Re: Comment on trim string function please
- From: Bill Reid
- Re: Comment on trim string function please
- From: Willem
- Comment on trim string function please
- Prev by Date: Re: What is the meaning of this warning, and how do I get rid of it?
- Next by Date: Re: Comment on trim string function please
- Previous by thread: Re: Comment on trim string function please
- Next by thread: Re: Comment on trim string function please
- Index(es):
Relevant Pages
|