Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 247109e

Browse files
committed
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.
1 parent 2a4df12 commit 247109e

2 files changed

Lines changed: 0 additions & 12 deletions

File tree

Objects/unicodeobject.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10375,16 +10375,7 @@ unicode_compare(PyObject *str1, PyObject *str2)
1037510375
break;
1037610376
case PyUnicode_2BYTE_KIND:
1037710377
{
10378-
#if defined(HAVE_WMEMCMP) && SIZEOF_WCHAR_T == 2
10379-
int cmp = wmemcmp((wchar_t *)data1, (wchar_t *)data2, len);
10380-
/* normalize result of wmemcmp() into the range [-1; 1] */
10381-
if (cmp < 0)
10382-
return -1;
10383-
if (cmp > 0)
10384-
return 1;
10385-
#else
1038610378
COMPARE(Py_UCS2, Py_UCS2);
10387-
#endif
1038810379
break;
1038910380
}
1039010381
case PyUnicode_4BYTE_KIND:

PC/pyconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
645645
#define HAVE_WCSXFRM 1
646646
#endif
647647

648-
/* Define to 1 if you have the `wmemcmp' function. */
649-
#define HAVE_WMEMCMP 1
650-
651648
/* Define if the zlib library has inflateCopy */
652649
#define HAVE_ZLIB_COPY 1
653650

0 commit comments

Comments
 (0)