From f237d6cf0c8fb9e8f96e8f5665d00049d6ffe3c4 Mon Sep 17 00:00:00 2001 From: Shubham Patel <165564832+shubham0x13@users.noreply.github.com> Date: Tue, 5 Nov 2024 19:07:37 +0530 Subject: [PATCH] Optimize `full_text` setter to skip redundant updates --- adafruit_display_text/scrolling_label.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adafruit_display_text/scrolling_label.py b/adafruit_display_text/scrolling_label.py index 476e27c..2a2b6e5 100644 --- a/adafruit_display_text/scrolling_label.py +++ b/adafruit_display_text/scrolling_label.py @@ -141,9 +141,10 @@ def full_text(self) -> str: def full_text(self, new_text: str) -> None: if new_text and new_text[-1] != " ": new_text = "{} ".format(new_text) - self._full_text = new_text - self.current_index = 0 - self.update(True) + if new_text != self._full_text: + self._full_text = new_text + self.current_index = 0 + self.update(True) @property def text(self):