[Python-checkins] cpython: Optimize findchar() for PyUnicode_1BYTE_KIND: use memchr and memrchr
victor.stinner
python-checkins at python.org
Thu Oct 13 01:17:29 CEST 2011
http://hg.python.org/cpython/rev/e5bd48b43a58
changeset: 72903:e5bd48b43a58
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Thu Oct 13 00:18:12 2011 +0200
summary:
Optimize findchar() for PyUnicode_1BYTE_KIND: use memchr and memrchr
files:
Objects/unicodeobject.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -530,6 +530,14 @@
{
/* like wcschr, but doesn't stop at NULL characters */
Py_ssize_t i;
+ if (kind == 1) {
+ if (direction == 1)
+ return memchr(s, ch, size);
+#ifdef HAVE_MEMRCHR
+ else
+ return memrchr(s, ch, size);
+#endif
+ }
if (direction == 1) {
for(i = 0; i < size; i++)
if (PyUnicode_READ(kind, s, i) == ch)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list