Efficient STRing CoMPares?

Henry Spencer henry at zoo.toronto.edu
Thu Mar 21 03:44:52 AEST 1991


In article <1991Mar19.034802.24340 at cbnewsk.att.com> barton at 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 at zoo.toronto.edu  utzoo!henry



More information about the Comp.lang.c mailing list