TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Kurt Kuzba
from: Frank Adam
date: 1998-11-10 13:04:20
subject: printf()

On Nov 08 07:24, 1998, Kurt Kuzba of 1:154/750 wrote:
G'day Kurt,

FA>>  printf("%s\n",ltrim(ltrimchar(trimchar(ltrimchar(ltrimchar
FA>>     (ltrim("    Hello World"),'H'),'e'),'l'),'o')) );
KK>    A small tear of joy has formed in the corner of my eye! ;)
It's sick enough to make anyone cry. ;-) 

KK>    I might suggest a minor alteration as a speed optimization:

KK>    Removing mathematical calculations in the code where a
I could go with the lame reply "but compilers will optimize that"
, but probably older ones will not. 
It's quite good, let's take it a step further and remove strchr() as well.. 

char* del_chr(char *s,int ch)
{
 char *p = s;
 int len = strlen(s)+1;
 while(*p)
 {
  if(*p == ch)
    memmove(p--,p+1,len--);
    else
     len--;
    p++;
  }
 return p;
}
This may or may not speed up things though, if (and i'm assuming it is) the
overhead of the function call to strchr is larger than the time it takes
for 10-15 pointer increments i figure in general this would be quicker. 

KK>    required an impassioned response, my having been provoked,
KK>    in my twisted little mind, beyond all reason. 
:-) 
Now how do we remove memmove() ? ;-)

 Regards, Frank. Email: fadam{at}sensation.net.au. 

--- Msged/386 4.30 PE
* Origin: The ticking point, Melbourne, Australia. (3:635/728.21{at}fidonet)
SEEN-BY: 633/267 270 635/506 728 670/218
@PATH: 635/728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.