Skip to content

Commit 148131c

Browse files
author
Kevin J Walters
committed
Making text updates more memory/gc efficient by only splitting on tabs if a tab is present. #166
1 parent 8ca8663 commit 148131c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adafruit_display_text/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def __init__(
283283
self._y_offset = self._ascent // 2
284284

285285
def _get_ascent_descent(self) -> Tuple[int, int]:
286-
""" Private function to calculate ascent and descent font values """
286+
"""Private function to calculate ascent and descent font values"""
287287
if hasattr(self.font, "ascent") and hasattr(self.font, "descent"):
288288
return self.font.ascent, self.font.descent
289289

@@ -462,4 +462,4 @@ def label_direction(self, new_label_direction: str) -> None:
462462
self._set_label_direction(new_label_direction)
463463

464464
def _replace_tabs(self, text: str) -> str:
465-
return self._tab_text.join(text.split("\t"))
465+
return text if text.find("\t") < 0 else self._tab_text.join(text.split("\t"))

0 commit comments

Comments
 (0)