Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Efficient STRing CoMPares?
Message-ID: <1991Mar20.174452.4246@zoo.toronto.edu>
Date: Wed, 20 Mar 1991 17:44:52 GMT
References: <1991Mar15.142821@mars.mpr.ca> <15486@smoke.brl.mil> <1991Mar19.034802.24340@cbnewsk.att.com>
Organization: U of Toronto Zoology

In article <1991Mar19.034802.24340@cbnewsk.att.com> barton@cbnewsk.att.com (jim.m.barton) writes:
>... The above macro, StrEq(), MIGHT be faster if most
>of the strings being compared tend to differ in their first character...
>IMHO, I doubt that StrEq() will acheive any significant optimization for
>MOST cases...

Sorry, there is considerable experimental evidence that it does.  The fact
is, most string comparisons fail on the very first character, and even a
compiler-inlined strcmp() -- not all that common in the Unix world yet,
thanks to our geriatric compilers -- is generally a more expensive way
of discovering this.
-- 
"[Some people] positively *wish* to     | Henry Spencer @ U of Toronto Zoology
believe ill of the modern world."-R.Peto|  henry@zoo.toronto.edu  utzoo!henry
