diff options
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index a7a3151..f6bf505 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5070,25 +5070,16 @@ static Py_ssize_t ascii_decode(const char *start, const char *end, Py_UCS1 *dest) { const char *p = start; - const char *aligned_end = (const char *) _Py_ALIGN_DOWN(end, SIZEOF_SIZE_T); - - /* - * Issue #17237: m68k is a bit different from most architectures in - * that objects do not use "natural alignment" - for example, int and - * long are only aligned at 2-byte boundaries. Therefore the assert() - * won't work; also, tests have shown that skipping the "optimised - * version" will even speed up m68k. - */ -#if !defined(__m68k__) + #if SIZEOF_SIZE_T <= SIZEOF_VOID_P - assert(_Py_IS_ALIGNED(dest, SIZEOF_SIZE_T)); - if (_Py_IS_ALIGNED(p, SIZEOF_SIZE_T)) { + assert(_Py_IS_ALIGNED(dest, ALIGNOF_SIZE_T)); + if (_Py_IS_ALIGNED(p, ALIGNOF_SIZE_T)) { /* Fast path, see in STRINGLIB(utf8_decode) for an explanation. */ /* Help allocation */ const char *_p = p; Py_UCS1 * q = dest; - while (_p < aligned_end) { + while (_p + SIZEOF_SIZE_T <= end) { size_t value = *(const size_t *) _p; if (value & ASCII_CHAR_MASK) break; @@ -5105,14 +5096,13 @@ ascii_decode(const char *start, const char *end, Py_UCS1 *dest) return p - start; } #endif -#endif while (p < end) { /* Fast path, see in STRINGLIB(utf8_decode) in stringlib/codecs.h for an explanation. */ - if (_Py_IS_ALIGNED(p, SIZEOF_SIZE_T)) { + if (_Py_IS_ALIGNED(p, ALIGNOF_SIZE_T)) { /* Help allocation */ const char *_p = p; - while (_p < aligned_end) { + while (_p + SIZEOF_SIZE_T <= end) { size_t value = *(const size_t *) _p; if (value & ASCII_CHAR_MASK) break; |