Browse Source

Use built-in isascii instead of regex

pull/8351/head
Rapptz 3 years ago
parent
commit
f52a02359d
  1. 10
      discord/utils.py

10
discord/utils.py

@ -764,14 +764,10 @@ class SnowflakeList(_SnowflakeListBase):
return i != len(self) and self[i] == element return i != len(self) and self[i] == element
_IS_ASCII = re.compile(r'^[\x00-\x7f]+$') def _string_width(string: str) -> int:
def _string_width(string: str, *, _IS_ASCII=_IS_ASCII) -> int:
"""Returns string's width.""" """Returns string's width."""
match = _IS_ASCII.match(string) if string.isascii():
if match: return len(string)
return match.endpos
UNICODE_WIDE_CHAR_TYPE = 'WFA' UNICODE_WIDE_CHAR_TYPE = 'WFA'
func = unicodedata.east_asian_width func = unicodedata.east_asian_width

Loading…
Cancel
Save