diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-11 23:22:22 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-11 23:22:22 +0200 |
commit | 8cc70dcf7020f1e5c286fed5b2a1034f5ba36afe (patch) | |
tree | db00355ce68c1bfaab38405c9400c22f31b6c7db /Objects/stringlib/fastsearch.h | |
parent | c5af7730e34f15d917730c66076125d4e545f11a (diff) | |
download | cpython-git-8cc70dcf7020f1e5c286fed5b2a1034f5ba36afe.tar.gz |
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
Diffstat (limited to 'Objects/stringlib/fastsearch.h')
-rw-r--r-- | Objects/stringlib/fastsearch.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h index 33ab6ff94e..085ec6a3d2 100644 --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -115,11 +115,17 @@ FASTSEARCH(const STRINGLIB_CHAR* s, Py_ssize_t n, 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); |