From f52a02359de5d7f14a8cddee6fa9833d62c26604 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 17 Aug 2022 01:52:29 -0400 Subject: [PATCH] Use built-in isascii instead of regex --- discord/utils.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/discord/utils.py b/discord/utils.py index 51251d81d..af2d553de 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -764,14 +764,10 @@ class SnowflakeList(_SnowflakeListBase): return i != len(self) and self[i] == element -_IS_ASCII = re.compile(r'^[\x00-\x7f]+$') - - -def _string_width(string: str, *, _IS_ASCII=_IS_ASCII) -> int: +def _string_width(string: str) -> int: """Returns string's width.""" - match = _IS_ASCII.match(string) - if match: - return match.endpos + if string.isascii(): + return len(string) UNICODE_WIDE_CHAR_TYPE = 'WFA' func = unicodedata.east_asian_width