From a0cd28809a03f14a874e39b01d913705a78cffe3 Mon Sep 17 00:00:00 2001 From: Brian Pepple Date: Thu, 19 Dec 2024 09:56:59 -0500 Subject: [PATCH] Reduce string object creation by using a single string formatting operation --- metrontagger/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metrontagger/utils.py b/metrontagger/utils.py index d3c4364..700b991 100644 --- a/metrontagger/utils.py +++ b/metrontagger/utils.py @@ -16,8 +16,7 @@ def create_print_title(txt: str) -> str: Returns: str: The formatted title string, including newlines and dashes. """ - result = f"\n{txt}\n" - return result + "-" * len(txt) + return f"\n{txt}\n{txt.replace(txt, '-' * len(txt))}" def cleanup_string(path_name: int | str | None) -> str | None: