diff --git a/src/include/port/pg_utf8.h b/src/include/port/pg_utf8.h index dac2afc130..a0c94dd4f3 100644 --- a/src/include/port/pg_utf8.h +++ b/src/include/port/pg_utf8.h @@ -53,26 +53,25 @@ extern int pg_validate_utf8_fallback(const unsigned char *s, int len); static inline int check_ascii(const unsigned char *s, int len) { - uint64 half1, half2, + uint64 chunk, highbit_mask; - if (len >= 2 * sizeof(uint64)) + if (len >= sizeof(uint64)) { - memcpy(&half1, s, sizeof(uint64)); - memcpy(&half2, s + sizeof(uint64), sizeof(uint64)); + memcpy(&chunk, s, sizeof(uint64)); /* * If there are any zero bytes, bail and let the slow * path handle it. */ - if (HAS_ZERO(half1) || HAS_ZERO(half2)) + if (HAS_ZERO(chunk)) return 0; /* Check if any bytes in this chunk have the high bit set. */ - highbit_mask = ((half1 | half2) & UINT64CONST(0x8080808080808080)); + highbit_mask = (chunk & UINT64CONST(0x8080808080808080)); if (!highbit_mask) - return 2 * sizeof(uint64); + return sizeof(uint64); else return 0; }