diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-14 13:42:17 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-14 13:42:17 (GMT) |
commit | 413fdcea21908055cb8acad28a94b8f72eb2ffec (patch) | |
tree | 59d06812d65d6fab8c8a0bea714f0b2cc0736110 /Objects/bytesobject.c | |
parent | 0304729ec49f4673bc8c88740537e66643a6c44a (diff) | |
download | cpython-413fdcea21908055cb8acad28a94b8f72eb2ffec.zip cpython-413fdcea21908055cb8acad28a94b8f72eb2ffec.tar.gz cpython-413fdcea21908055cb8acad28a94b8f72eb2ffec.tar.bz2 |
Issue #24821: Refactor STRINGLIB(fastsearch_memchr_1char) and split it on
STRINGLIB(find_char) and STRINGLIB(rfind_char) that can be used independedly
without special preconditions.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index c10dbdf..6a9e062 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1937,16 +1937,15 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) ADJUST_INDICES(start, end, len); if (end - start < sub_len) res = -1; - else if (sub_len == 1 -#ifndef HAVE_MEMRCHR - && dir > 0 -#endif - ) { - unsigned char needle = *sub; - int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH; - res = stringlib_fastsearch_memchr_1char( - PyBytes_AS_STRING(self) + start, end - start, - needle, needle, mode); + else if (sub_len == 1) { + if (dir > 0) + res = stringlib_find_char( + PyBytes_AS_STRING(self) + start, end - start, + *sub); + else + res = stringlib_rfind_char( + PyBytes_AS_STRING(self) + start, end - start, + *sub); if (res >= 0) res += start; } |