Mercurial > cpython-lru_cache-weakref
diff Objects/stringlib/fastsearch.h @ 72874:bfd3fcfb02f3
Fix fastsearch for UCS2 and UCS4
* If needle is 0, try (p[0] >> 16) & 0xff for UCS4
* Disable fastsearch_memchr_1char() if needle is zero for UCS2 and UCS4
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 11 Oct 2011 23:22:22 +0200 |
| parents | af4a89f4f466 |
| children | c61137ff5f52 |
line wrap: on
line diff
--- a/Objects/stringlib/fastsearch.h Tue Oct 11 23:00:31 2011 +0200 +++ b/Objects/stringlib/fastsearch.h Tue Oct 11 23:22:22 2011 +0200 @@ -115,11 +115,17 @@ unsigned char needle; int use_needle = 1; needle = p[0] & 0xff; - if (needle == 0 && sizeof(STRINGLIB_CHAR) > 1) { +#if STRINGLIB_SIZEOF_CHAR > 1 + if (needle == 0) { needle = (p[0] >> 8) & 0xff; - if (needle >= 32) +#if STRINGLIB_SIZEOF_CHAR > 2 + if (needle == 0) + needle = (p[0] >> 16) & 0xff; +#endif + if (needle >= 32 || needle == 0) use_needle = 0; } +#endif if (use_needle) return STRINGLIB(fastsearch_memchr_1char) (s, n, p[0], needle, maxcount, mode);
