Kaydet (Commit) c8fe0448 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind()

for single-byte argument on Linux.
...@@ -32,6 +32,9 @@ Release date: 2015-07-26 ...@@ -32,6 +32,9 @@ Release date: 2015-07-26
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind()
for single-byte argument on Linux.
- Issue #24569: Make PEP 448 dictionary evaluation more consistent. - Issue #24569: Make PEP 448 dictionary evaluation more consistent.
- Issue #24583: Fix crash when set is mutated while being updated. - Issue #24583: Fix crash when set is mutated while being updated.
......
...@@ -1171,12 +1171,16 @@ bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir) ...@@ -1171,12 +1171,16 @@ bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
ADJUST_INDICES(start, end, len); ADJUST_INDICES(start, end, len);
if (end - start < sub_len) if (end - start < sub_len)
res = -1; res = -1;
/* Issue #23573: FIXME, windows has no memrchr() */ else if (sub_len == 1
else if (sub_len == 1 && dir > 0) { #ifndef HAVE_MEMRCHR
&& dir > 0
#endif
) {
unsigned char needle = *sub; unsigned char needle = *sub;
int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
res = stringlib_fastsearch_memchr_1char( res = stringlib_fastsearch_memchr_1char(
PyByteArray_AS_STRING(self) + start, end - start, PyByteArray_AS_STRING(self) + start, end - start,
needle, needle, FAST_SEARCH); needle, needle, mode);
if (res >= 0) if (res >= 0)
res += start; res += start;
} }
......
...@@ -1815,12 +1815,16 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) ...@@ -1815,12 +1815,16 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir)
ADJUST_INDICES(start, end, len); ADJUST_INDICES(start, end, len);
if (end - start < sub_len) if (end - start < sub_len)
res = -1; res = -1;
/* Issue #23573: FIXME, windows has no memrchr() */ else if (sub_len == 1
else if (sub_len == 1 && dir > 0) { #ifndef HAVE_MEMRCHR
&& dir > 0
#endif
) {
unsigned char needle = *sub; unsigned char needle = *sub;
int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
res = stringlib_fastsearch_memchr_1char( res = stringlib_fastsearch_memchr_1char(
PyBytes_AS_STRING(self) + start, end - start, PyBytes_AS_STRING(self) + start, end - start,
needle, needle, FAST_SEARCH); needle, needle, mode);
if (res >= 0) if (res >= 0)
res += start; res += start;
} }
......
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