summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib/ucs4lib.h
diff options
context:
space:
mode:
authorgoldsteinn <35538541+goldsteinn@users.noreply.github.com>2022-05-24 01:45:31 (GMT)
committerGitHub <noreply@github.com>2022-05-24 01:45:31 (GMT)
commit7108bdf27c7a460cf83c4a01dea54ae4591d8aea (patch)
tree0ebf080594979a194459f6d5f4f30cb6fafffdac /Objects/stringlib/ucs4lib.h
parentf7fabae75c7b8ecd0c5673b5d62a15db24a05953 (diff)
downloadcpython-7108bdf27c7a460cf83c4a01dea54ae4591d8aea.zip
cpython-7108bdf27c7a460cf83c4a01dea54ae4591d8aea.tar.gz
cpython-7108bdf27c7a460cf83c4a01dea54ae4591d8aea.tar.bz2
gh-93033: Use wmemchr in stringlib (GH-93034)
Generally comparable perf for the "good" case where memchr doesn't return any collisions (false matches on lower byte) but clearly faster with collisions.
Diffstat (limited to 'Objects/stringlib/ucs4lib.h')
-rw-r--r--Objects/stringlib/ucs4lib.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/stringlib/ucs4lib.h b/Objects/stringlib/ucs4lib.h
index 57344f2..def4ca5 100644
--- a/Objects/stringlib/ucs4lib.h
+++ b/Objects/stringlib/ucs4lib.h
@@ -21,6 +21,10 @@
#define STRINGLIB_CHECK PyUnicode_Check
#define STRINGLIB_CHECK_EXACT PyUnicode_CheckExact
#define STRINGLIB_MUTABLE 0
+#if SIZEOF_WCHAR_T == 4
+#define STRINGLIB_FAST_MEMCHR(s, c, n) \
+ (Py_UCS4 *)wmemchr((const wchar_t *)(s), c, n)
+#endif
#define STRINGLIB_TOSTR PyObject_Str
#define STRINGLIB_TOASCII PyObject_ASCII