From 9e7f363aebe01542210633dd4027ce777bf31e3c Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 31 Oct 2024 15:48:27 +0000 Subject: [PATCH] use sets --- rich/cells.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rich/cells.py b/rich/cells.py index 17793eb5..06a57b2c 100644 --- a/rich/cells.py +++ b/rich/cells.py @@ -1,15 +1,19 @@ from __future__ import annotations -import re from functools import lru_cache from typing import Callable from ._cell_widths import CELL_WIDTHS -# Regex to match sequence of the most common character ranges -_is_single_cell_widths = re.compile( - "^[\u0020-\u007e\u00a0-\u02ff\u0370-\u0482\u2500-\u25FF]*$" -).match +_SINGLE_CELLS = frozenset( + [ + *map(chr, range(0x20, 0x7E + 1)), + *map(chr, range(0xA0, 0x02FF + 1)), + *map(chr, range(0x0370, 0x0482 + 1)), + *map(chr, range(0x2500, 0x25FF + 1)), + ] +) +_is_single_cell_widths = _SINGLE_CELLS.issuperset @lru_cache(4096)