Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!nbires!vianet!devine From: devine@vianet.UUCP (Bob Devine) Newsgroups: comp.lang.c Subject: Re: STREQ Message-ID: <202@vianet.UUCP> Date: Tue, 14-Jul-87 20:07:49 EDT Article-I.D.: vianet.202 Posted: Tue Jul 14 20:07:49 1987 Date-Received: Fri, 17-Jul-87 04:04:41 EDT References: <8011@brl-adm.ARPA>, <1711@umn-cs.UUCP> <8277@utzoo.UUCP> Organization: Western Digital, Boulder Tech Ctr Lines: 21 Summary: a definite speed-up In article <8277@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes: * > >>#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) * > * > This will also greatly slow a good many programs down on machines * > that do not support byte addressing. * * No, not really. Think about it: all the macro is doing is duplicating * the first test that strcmp has to do. Strcmp has to do it anyway, and * will probably have to do it much the same way. (There are tricks that * can be used to do some string operations a word at a time, but they fall * down badly when the two strings are not aligned the same way -- a frequent * occurrence.) I used a 4-char compare inside a string compare for a spelling checker that I wrote a looong time ago. It sped the checker up considerably. This was for an implementation that I knew would give me the correct alignment so that scarfing up the first 4 chars into an int was easy. Plus I was only concerned about equal/not-equal; there was no need for checking if a word was ordered before or after the second word. Bob Devine