summaryrefslogtreecommitdiffstats
path: root/Objects/bytes_methods.c
diff options
context:
space:
mode:
authorMa Lin <animalize@users.noreply.github.com>2020-10-18 14:48:38 (GMT)
committerGitHub <noreply@github.com>2020-10-18 14:48:38 (GMT)
commita0c603cb9d4dbb9909979313a88bcd1f5fde4f62 (patch)
tree4e25844a35bc4dd3436cec0087450e73720bac42 /Objects/bytes_methods.c
parent3635388f52b42e5280229104747962117104c453 (diff)
downloadcpython-a0c603cb9d4dbb9909979313a88bcd1f5fde4f62.zip
cpython-a0c603cb9d4dbb9909979313a88bcd1f5fde4f62.tar.gz
cpython-a0c603cb9d4dbb9909979313a88bcd1f5fde4f62.tar.bz2
bpo-38252: Use 8-byte step to detect ASCII sequence in 64bit Windows build (GH-16334)
Diffstat (limited to 'Objects/bytes_methods.c')
-rw-r--r--Objects/bytes_methods.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index 72daa1f..1512086 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -100,14 +100,14 @@ Return True if B is empty or all characters in B are ASCII,\n\
False otherwise.");
// Optimization is copied from ascii_decode in unicodeobject.c
-/* Mask to quickly check whether a C 'long' contains a
+/* Mask to quickly check whether a C 'size_t' contains a
non-ASCII, UTF8-encoded char. */
-#if (SIZEOF_LONG == 8)
-# define ASCII_CHAR_MASK 0x8080808080808080UL
-#elif (SIZEOF_LONG == 4)
-# define ASCII_CHAR_MASK 0x80808080UL
+#if (SIZEOF_SIZE_T == 8)
+# define ASCII_CHAR_MASK 0x8080808080808080ULL
+#elif (SIZEOF_SIZE_T == 4)
+# define ASCII_CHAR_MASK 0x80808080U
#else
-# error C 'long' size should be either 4 or 8!
+# error C 'size_t' size should be either 4 or 8!
#endif
PyObject*
@@ -115,20 +115,20 @@ _Py_bytes_isascii(const char *cptr, Py_ssize_t len)
{
const char *p = cptr;
const char *end = p + len;
- const char *aligned_end = (const char *) _Py_ALIGN_DOWN(end, SIZEOF_LONG);
+ const char *aligned_end = (const char *) _Py_ALIGN_DOWN(end, SIZEOF_SIZE_T);
while (p < end) {
/* Fast path, see in STRINGLIB(utf8_decode) in stringlib/codecs.h
for an explanation. */
- if (_Py_IS_ALIGNED(p, SIZEOF_LONG)) {
+ if (_Py_IS_ALIGNED(p, SIZEOF_SIZE_T)) {
/* Help allocation */
const char *_p = p;
while (_p < aligned_end) {
- unsigned long value = *(const unsigned long *) _p;
+ size_t value = *(const size_t *) _p;
if (value & ASCII_CHAR_MASK) {
Py_RETURN_FALSE;
}
- _p += SIZEOF_LONG;
+ _p += SIZEOF_SIZE_T;
}
p = _p;
if (_p == end)