Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ihnp4!ptsfa!lll-lcc!rutgers!sri-spam!robert From: robert@sri-spam.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: String Handling -- Incompetence of run-time libraries Message-ID: <9996@sri-spam.istc.sri.com> Date: Wed, 1-Apr-87 11:58:19 EST Article-I.D.: sri-spam.9996 Posted: Wed Apr 1 11:58:19 1987 Date-Received: Sat, 4-Apr-87 07:13:47 EST References: <15292@amdcad.UUCP> <978@ames.UUCP> <15694@sun.uucp> Reply-To: robert@sri-spam.UUCP (Robert Allen) Organization: SRI International, Menlo Park Lines: 40 Keywords: instruction set architectures, strcpy Xref: utgpu comp.arch:743 comp.lang.c:1417 In article <1359@steinmetz.steinmetz.UUCP> davidsen@kbsvax.steinmetz.UUCP (William E. Davidsen Jr) writes: >$In article <1944@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) pointed out >$that printf could be recoded to run much faster. >... >$strcpy2(ss1,ss2) >$char *ss1,*ss2;<---------------------------- put "register" on this line >${ register char *s1,*s2;<-------------- as many compilers will use this >$ as local variables overriding >$ s1 = ss1; the arguments. >$ s2 = ss2; >$ while (*s1++ = *s2++); } > >I'm going to try these on some of the machines I use, and see if this >will speed up things. To further speed this up you could write it as: strcpy2(ss1,ss2) register char *ss1, *ss2; { while (*s1++ = *s2++) ; } thus eliminating two assignments and two local variables. -- --------------------------------------------------------- Glover (upon discovering that Gibson is his new partner): "God hates me, that's what the problem is!" Gibson (blowing cigarette smoke out his nose): "Hate 'em back, it works for me!" Gibson (later in the film, with handgun): "PUNTA, PUNTA, PUNTA!!" Robert Allen, robert@spam.istc.sri.com ---------------------------------------------------------