Commit 9e7a1bcf authored by Victor Stinner's avatar Victor Stinner

Optimize findchar() for PyUnicode_1BYTE_KIND: use memchr and memrchr

parent dd4e2f01
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment