more on TRUE and FALSE (side-comment)

Larry Jones scjones at thor.UUCP
Fri Sep 21 00:51:54 AEST 1990


In article <1990Sep18.163533.16008 at zoo.toronto.edu>, henry at zoo.toronto.edu (Henry Spencer) writes:
> My current favorite definition is:
> 
> #define	STREQ(a, b)	(*(a) == *(b) && strcmp((a), (b)) == 0)
> 
> Note that this is an unsafe macro; on the other hand, it is typically
> much faster than one which just calls strcmp every time.  Most string
> comparisons fail on the first character.

And it's slower than one that just calls strcmp every time if your
compiler is smart enough to generate in-line code for strcmp!

Of course, the beauty of a macro is that you can change it without
having to change all the code that uses it.
----
Larry Jones                         UUCP: uunet!sdrc!thor!scjones
SDRC                                      scjones at thor.UUCP
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
Nobody knows how to pamper like a Mom. -- Calvin



More information about the Comp.lang.c mailing list