summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-12 22:18:12 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-12 22:18:12 (GMT)
commit9e7a1bcfd6737de148dd99c953e1d079ad3f239a (patch)
tree8546c0605026040540f43bdb08565016d8ab667a
parentdd4e2f01537506d152684d5dfb87ea8e1e3c4a9c (diff)
downloadcpython-9e7a1bcfd6737de148dd99c953e1d079ad3f239a.zip
cpython-9e7a1bcfd6737de148dd99c953e1d079ad3f239a.tar.gz
cpython-9e7a1bcfd6737de148dd99c953e1d079ad3f239a.tar.bz2
Optimize findchar() for PyUnicode_1BYTE_KIND: use memchr and memrchr
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index e199a11..5766237 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -530,6 +530,14 @@ Py_LOCAL_INLINE(char *) findchar(void *s, int kind,
{
/* 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)