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

  1. From: fraser@edc.UUCP (Fraser Orr)
  2. Newsgroups: alt.sources
  3. Subject: Re: Fast strcmp() wanted.
  4. Message-ID: <1646@cherry.edc.UUCP>
  5. Date: 26 Sep 90 16:26:26 GMT
  6.  
  7. In article <12145@crdgw1.crd.ge.com> larocque@jupiter.crd.ge.com (David M. LaRocque) writes:
  8. >After I profiled my C program I discovered that the function
  9. >strcmp() takes one third of my program's CPU time.  I was hoping
  10. >someone may have written their own version of strcmp() that
  11. >outperforms the library's function.
  12.  
  13. One quick dirty thing I did once was to change
  14.  
  15.     if (strcmp (a,b)==0)
  16. to
  17.     if (*a==*b && (strcmp(a.b)==0))
  18.  
  19. I seem to remember a remarkable performance improvement, like about 5
  20. times faster.  Probably due to the fact that the program mainly did
  21. strcmp and the strcmp was pretty bad.
  22.  
  23. Worth considering anyway.
  24.  
  25. ==Fraser Orr <fraser@edc.uucp> +44 506 416778x206
  26. UseNet: {uunet,sun}!atexnet!fraser JANet: fraser%edc@cs.hw.ac.uk
  27.