From 08821053743c55e49ce790d41973261e6091da34 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 16 Mar 2020 22:33:27 +0000 Subject: [PATCH] Shortcut for ascii chars --- rich/cells.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rich/cells.py b/rich/cells.py index 68238e91..2e650694 100644 --- a/rich/cells.py +++ b/rich/cells.py @@ -31,6 +31,11 @@ def get_character_cell_size(character: str, _table=CELL_WIDTHS) -> int: assert len(character) == 1, "'character' should have a length of 1" codepoint = ord(character) + + if 127 > codepoint > 31: + # Shortcut for ascii + return 1 + lower_bound = 0 upper_bound = len(_table) - 1 index = (lower_bound + upper_bound) // 2