[m-rev.] diff: six percent speedup

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 4 16:49:35 AEST 2005


On 30-Mar-2005, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> I think it would also be worth
> making the following alteration in runtime/mercury_string.h
> 
> #define MR_string_equal(s1,s2) (strcmp((char*)(s1),(char*)(s2))==0)
> 
> to
> 
> #define MR_string_equal(s1,s2) \
> 	((char*)(s1)==(char*)(s2) || strcmp((char*)(s1),(char*)(s2))==0)
> 
> as part of this change.

I suggest benchmarking it first.

> I've checked the definition of strcmp on ceres
> (/usr/include/bits/string.h) and it doesn't appear to check for pointer
> equality before checking for string equality.

That's not always the right place to look for the definition of strcmp().
GNU C will recognize strcmp() and may generate inline code for it.
For example it does that in the case when one of the strings is a
string literal.

-- 
Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list