Kaydet (Commit) dabbfe7b authored tarafından Victor Stinner's avatar Victor Stinner

Issue #23573: Fix bytes.rfind() and bytearray.rfind() on Windows

Windows has no memrchr() function.

This change is only a workaround, the optimization must be reenabled on other
platforms.
üst 39183dfc
...@@ -1166,7 +1166,8 @@ bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir) ...@@ -1166,7 +1166,8 @@ 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;
else if (sub_len == 1) { /* Issue #23573: FIXME, windows has no memrchr() */
else if (sub_len == 1 && dir > 0) {
unsigned char needle = *sub; unsigned char needle = *sub;
int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH; int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
res = stringlib_fastsearch_memchr_1char( res = stringlib_fastsearch_memchr_1char(
......
...@@ -1938,7 +1938,8 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) ...@@ -1938,7 +1938,8 @@ 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;
else if (sub_len == 1) { /* Issue #23573: FIXME, windows has no memrchr() */
else if (sub_len == 1 && dir > 0) {
unsigned char needle = *sub; unsigned char needle = *sub;
int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH; int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
res = stringlib_fastsearch_memchr_1char( res = stringlib_fastsearch_memchr_1char(
......
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