Efficient STRing CoMPares?

Chris Torek torek at elf.ee.lbl.gov
Wed Mar 20 05:17:20 AEST 1991


In article <15510 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>... in the vast majority of applications the strings being
>compared, even in cases where they match, are contained in different
>storage locations.  E.g.
>	if ( StrEq( buffer, "EOF" ) ) ...

Of course, you can build yourself a `string pool' system, in which each
distinct string appears exactly once, and then two strings match iff their
pointers match . . . but this merely offloads the `compare for truly
equal' into the string pool system.

If you need to do many compares, this is probably worthwhile anyway.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list