[m-dev.] Equality and pointer equality

Ralph Becket rafe at cs.mu.OZ.AU
Fri Oct 8 09:54:37 AEST 2004


It just occurred to me to wonder whether the Mercury equality tests
first test for word/pointer equality before doing anything more
complicated?  For instance, in runtime/mercury_string.h we have

#define MR_string_equal(s1,s2) (strcmp((char*)(s1),(char*)(s2))==0)

This might be faster:

#define MR_string_equal(s1,s2) ((s1)==(s2) || strcmp((char*)(s1),(char*)(s2))==0)

(From /usr/src/kernel-source-2.2.17/lib/string.c, strcmp doesn't first test
for pointer equality, so this test isn't redundant.)

-- Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list