changeset: 96965:c06410c68217 parent: 96963:350e18d4ce84 parent: 96964:311a4d28631b user: Serhiy Storchaka date: Mon Jul 20 22:58:29 2015 +0300 files: Misc/NEWS description: Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind() for single-byte argument on Linux. diff -r 350e18d4ce84 -r c06410c68217 Misc/NEWS --- a/Misc/NEWS Mon Jul 20 17:13:28 2015 +0200 +++ b/Misc/NEWS Mon Jul 20 22:58:29 2015 +0300 @@ -32,6 +32,9 @@ 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 #24583: Fix crash when set is mutated while being updated. diff -r 350e18d4ce84 -r c06410c68217 Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Mon Jul 20 17:13:28 2015 +0200 +++ b/Objects/bytearrayobject.c Mon Jul 20 22:58:29 2015 +0300 @@ -1171,12 +1171,16 @@ 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; } diff -r 350e18d4ce84 -r c06410c68217 Objects/bytesobject.c --- a/Objects/bytesobject.c Mon Jul 20 17:13:28 2015 +0200 +++ b/Objects/bytesobject.c Mon Jul 20 22:58:29 2015 +0300 @@ -1815,12 +1815,16 @@ 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( PyBytes_AS_STRING(self) + start, end - start, - needle, needle, FAST_SEARCH); + needle, needle, mode); if (res >= 0) res += start; }