Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!cs.uoregon.edu!ns.uoregon.edu!milton!uw-beaver!mit-eddie!bbn.com!papaya.bbn.com!rsalz From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.lang.c Subject: Re: Efficient STRing CoMPares? Message-ID: <3401@litchi.bbn.com> Date: 19 Mar 91 06:24:43 GMT References: <1991Mar15.142821@mars.mpr.ca> <15486@smoke.brl.mil> <1193@caslon.cs.arizona.edu> <15496@smoke.brl.mil> <1991Mar18.174207.7377@bingvaxu.cc.binghamton.edu> Organization: BBN Systems and Technology, Inc. Lines: 18 In <1991Mar18.174207.7377@bingvaxu.cc.binghamton.edu> consp06@bingsuns.cc.binghamton.edu (Robert Konigsberg) writes: | Wouldn't it be good then, to include in the macro, |something to compare the actual POINTERS? If the pointers are the |same then the two strings have no CHOICE but to be equivelant. This |would really cut down the time under certain situations. If you're careful about the circumstances under which you use it, you might want to do something like this: #define EQ(p, q) \ ((p) == (q) || ((p)[0] == (q)[0] && strcmp((p), (q)) == 0)) I did this in Coda ("File distribution alternative to rdist", comp.sources.unix Volume 21) which builds lots of structures with shared strings. I got a slight performance gain (1 or 2%, I think). It's the difference between (eq ... ) and (equal ...), right-p? /r$ -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.