Fast strcmp() wanted.
Otto J. Makela
otto at tukki.jyu.fi
Thu Sep 27 22:56:43 AEST 1990
In article <1646 at cherry.edc.UUCP> fraser at edc.UUCP (Fraser Orr) writes:
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.
This should obviously be:
if(*a==*b && (strcmp(a,b)==0))
(just in case...)
I'd believe if your compiler is really brain-damaged, this could also help
a teeny weeny bit:
if(*a==*b && (!strcmp(a,b)))
--
/* * * Otto J. Makela <otto at jyu.fi> * * * * * * * * * * * * * * * * * * */
/* Phone: +358 41 613 847, BBS: +358 41 211 562 (CCITT, Bell 24/12/300) */
/* Mail: Kauppakatu 1 B 18, SF-40100 Jyvaskyla, Finland, EUROPE */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * * * * * */
More information about the Alt.sources
mailing list