Skip to content

Commit 9e7f363

Browse files
committed
use sets
1 parent afcc5c5 commit 9e7f363

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

rich/cells.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
from __future__ import annotations
22

3-
import re
43
from functools import lru_cache
54
from typing import Callable
65

76
from ._cell_widths import CELL_WIDTHS
87

9-
# Regex to match sequence of the most common character ranges
10-
_is_single_cell_widths = re.compile(
11-
"^[\u0020-\u007e\u00a0-\u02ff\u0370-\u0482\u2500-\u25FF]*$"
12-
).match
8+
_SINGLE_CELLS = frozenset(
9+
[
10+
*map(chr, range(0x20, 0x7E + 1)),
11+
*map(chr, range(0xA0, 0x02FF + 1)),
12+
*map(chr, range(0x0370, 0x0482 + 1)),
13+
*map(chr, range(0x2500, 0x25FF + 1)),
14+
]
15+
)
16+
_is_single_cell_widths = _SINGLE_CELLS.issuperset
1317

1418

1519
@lru_cache(4096)

0 commit comments

Comments
 (0)