Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!ll-xn!ames!amdcad!tim
From: tim@amdcad.AMD.COM (Tim Olson)
Newsgroups: comp.lang.c
Subject: Re: string equality/comparison optimization
Message-ID: <17403@amdcad.AMD.COM>
Date: Tue, 7-Jul-87 21:08:52 EDT
Article-I.D.: amdcad.17403
Posted: Tue Jul  7 21:08:52 1987
Date-Received: Fri, 10-Jul-87 07:23:28 EDT
References: <8011@brl-adm.ARPA> <1711@umn-cs.UUCP> <1500@xanth.UUCP>
Reply-To: tim@amdcad.UUCP (Tim Olson)
Organization: Advanced Micro Devices, Inc., Sunnyvale, Ca.
Lines: 22

In article <1500@xanth.UUCP> kyle@xanth.UUCP writes:
+-----
| In article <1711@umn-cs.UUCP>, herndon@umn-cs.UUCP (Robert Herndon) writes:
| >   This will also greatly slow a good many programs down on machines
| > that do not support byte addressing.
| 
| But then wouldn't the comparison be just as slow using strcmp(), since it too
| must compare bytes?
+-----

It doesn't necessarily have to compare the strings byte-by-byte.  If the
processor is "big-endian," the comparison can occur a word at a time
until the terminating zero-byte is reached (this is how the Am29000 does
it -- see lengthy discussion in comp.arch & this news group about 3
months ago). However, even with a very slight overhead in procedure
call/return, it probably is still a benificial optimization to
explicitly compare the first characters before calling strcmp(). 


	-- Tim Olson
	Advanced Micro Devices
	(tim@amdcad.amd.com)