diff -r 7780757c6bab Makefile.pre.in --- a/Makefile.pre.in Thu Mar 07 01:23:01 2013 +0100 +++ b/Makefile.pre.in Thu Mar 07 00:48:52 2013 -0800 @@ -734,8 +734,8 @@ Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS) -Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h -Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h +Objects/dictobject.o: $(srcdir)/Objects/unicode_eq.h +Objects/setobject.o: $(srcdir)/Objects/unicode_eq.h $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES) $(OPCODETARGETGEN) $(OPCODETARGETS_H) diff -r 7780757c6bab Objects/dictobject.c --- a/Objects/dictobject.c Thu Mar 07 01:23:01 2013 +0100 +++ b/Objects/dictobject.c Thu Mar 07 00:48:52 2013 -0800 @@ -67,7 +67,7 @@ #define PyDict_MINSIZE_COMBINED 8 #include "Python.h" -#include "stringlib/eq.h" +#include "unicode_eq.h" typedef struct { /* Cached hash code of me_key. */ diff -r 7780757c6bab Objects/setobject.c --- a/Objects/setobject.c Thu Mar 07 01:23:01 2013 +0100 +++ b/Objects/setobject.c Thu Mar 07 00:48:52 2013 -0800 @@ -9,7 +9,7 @@ #include "Python.h" #include "structmember.h" -#include "stringlib/eq.h" +#include "unicode_eq.h" /* Set a key error with the specified argument, wrapping it in a * tuple automatically so that tuple keys are not unpacked as the diff -r 7780757c6bab Objects/unicode_eq.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects/unicode_eq.h Thu Mar 07 00:48:52 2013 -0800 @@ -0,0 +1,34 @@ +/* Fast unicode equal function optimized for dictobject.c and setobject.c */ + +/* Return 1 if two unicode objects are equal, 0 if not. + * unicode_eq() is called when the hash of two unicode objects is equal. + */ +Py_LOCAL_INLINE(int) +unicode_eq(PyObject *aa, PyObject *bb) +{ + register PyUnicodeObject *a = (PyUnicodeObject *)aa; + register PyUnicodeObject *b = (PyUnicodeObject *)bb; + + if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) { + assert(0 && "unicode_eq ready fail"); + return 0; + } + + if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b)) + return 0; + if (PyUnicode_GET_LENGTH(a) == 0) + return 1; + if (PyUnicode_KIND(a) != PyUnicode_KIND(b)) + return 0; + /* Just comparing the first byte is enough to see if a and b differ. + * If they are 2 byte or 4 byte character most differences will happen in + * the lower bytes anyways. + */ + if (PyUnicode_1BYTE_DATA(a)[0] != PyUnicode_1BYTE_DATA(b)[0]) + return 0; + if (PyUnicode_KIND(a) == PyUnicode_1BYTE_KIND && + PyUnicode_GET_LENGTH(a) == 1) + return 1; + return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b), + PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0; +}