Fast strcmp() wanted.

Fraser Orr fraser at edc.UUCP
Thu Sep 27 02:26:26 AEST 1990


In article <12145 at crdgw1.crd.ge.com> larocque at jupiter.crd.ge.com (David M. LaRocque) writes:
>After I profiled my C program I discovered that the function
>strcmp() takes one third of my program's CPU time.  I was hoping
>someone may have written their own version of strcmp() that
>outperforms the library's function.

One quick dirty thing I did once was to change

	if (strcmp (a,b)==0)
to
	if (*a==*b && (strcmp(a.b)==0))

I seem to remember a remarkable performance improvement, like about 5
times faster.  Probably due to the fact that the program mainly did
strcmp and the strcmp was pretty bad.

Worth considering anyway.

==Fraser Orr <fraser at edc.uucp> +44 506 416778x206
UseNet: {uunet,sun}!atexnet!fraser JANet: fraser%edc at cs.hw.ac.uk



More information about the Alt.sources mailing list