summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-07-20 19:58:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-07-20 19:58:02 (GMT)
commitd92d4efe3d1fba48e8b20ec42bec243abea32545 (patch)
tree37a801ab2b054ba930753ad7c0418b93f0efc903 /Objects/bytearrayobject.c
parent3d0b8422bcbed2c06394ac7dfc9e7cbfe910b220 (diff)
downloadcpython-d92d4efe3d1fba48e8b20ec42bec243abea32545.zip
cpython-d92d4efe3d1fba48e8b20ec42bec243abea32545.tar.gz
cpython-d92d4efe3d1fba48e8b20ec42bec243abea32545.tar.bz2
Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind()
for single-byte argument on Linux.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index dae80d9..5647b57 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -1171,12 +1171,16 @@ bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
ADJUST_INDICES(start, end, len);
if (end - start < sub_len)
res = -1;
- /* Issue #23573: FIXME, windows has no memrchr() */
- else if (sub_len == 1 && dir > 0) {
+ 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(
PyByteArray_AS_STRING(self) + start, end - start,
- needle, needle, FAST_SEARCH);
+ needle, needle, mode);
if (res >= 0)
res += start;
}