mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
Issue #17615: On Windows (VS2010), Performances of wmemcmp() to compare Unicode
strings are not convincing. For UCS2 (16-bit wchar_t type), use a dummy loop instead of wmemcmp(). The dummy loop is as fast, or a little bit faster. wchar_t is only 16-bit long on Windows. wmemcmp() is still used for 32-bit wchar_t.
This commit is contained in:
parent
2a4df127c7
commit
247109e74d
2 changed files with 0 additions and 12 deletions
|
@ -10375,16 +10375,7 @@ unicode_compare(PyObject *str1, PyObject *str2)
|
||||||
break;
|
break;
|
||||||
case PyUnicode_2BYTE_KIND:
|
case PyUnicode_2BYTE_KIND:
|
||||||
{
|
{
|
||||||
#if defined(HAVE_WMEMCMP) && SIZEOF_WCHAR_T == 2
|
|
||||||
int cmp = wmemcmp((wchar_t *)data1, (wchar_t *)data2, len);
|
|
||||||
/* normalize result of wmemcmp() into the range [-1; 1] */
|
|
||||||
if (cmp < 0)
|
|
||||||
return -1;
|
|
||||||
if (cmp > 0)
|
|
||||||
return 1;
|
|
||||||
#else
|
|
||||||
COMPARE(Py_UCS2, Py_UCS2);
|
COMPARE(Py_UCS2, Py_UCS2);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PyUnicode_4BYTE_KIND:
|
case PyUnicode_4BYTE_KIND:
|
||||||
|
|
|
@ -645,9 +645,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
|
||||||
#define HAVE_WCSXFRM 1
|
#define HAVE_WCSXFRM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the `wmemcmp' function. */
|
|
||||||
#define HAVE_WMEMCMP 1
|
|
||||||
|
|
||||||
/* Define if the zlib library has inflateCopy */
|
/* Define if the zlib library has inflateCopy */
|
||||||
#define HAVE_ZLIB_COPY 1
|
#define HAVE_ZLIB_COPY 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue