home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1897 < prev    next >
Internet Message Format  |  1990-12-28  |  1KB

  1. From: sartin@hplabsz.HPL.HP.COM (Rob Sartin)
  2. Newsgroups: alt.sources
  3. Subject: Re: Fast strcmp() wanted.
  4. Message-ID: <6003@hplabsz.HPL.HP.COM>
  5. Date: 3 Oct 90 19:33:38 GMT
  6.  
  7. In article <CEDMAN.90Sep29091115@lynx.ps.uci.edu> cedman@lynx.ps.uci.edu (Carl Edman) writes:
  8. >string structure (or better class, long live C++ ! :-) which calculates
  9. >a 32-bit CRC for each string the first time and stores it somewhere.
  10. >Then only 1 (inlined) longword-compare will do the stringcomparisons
  11. >for you.
  12.  
  13. Afraid not.  It'll give you an estimate of whether the strings match
  14. (correctly identifying those that don't).  You will need to then
  15. actually compare the strings if they are the same.  This method will
  16. also be unable to reproduce strcmp's behavior (strcmp returns a signed
  17. result indicated the <, =, > by being negative, zero, positive), it will
  18. only return a boolean (match, no match).
  19.  
  20. If you do lots of string comparisons strictly for equality/inequality it
  21. might be worth investigating.
  22.  
  23. Rob Sartin                    uucp: hplabs!sartin
  24. "Some may say that I have gone astray.        internet: sartin@hplabs.hp.com
  25. How would they know? They never follow."
  26.