From 424bd8a6cd222a69f7094a801dd701e53a0a3bcc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 May 2020 09:15:11 +0530 Subject: [PATCH] Only compile tab template once --- kitty/tab_bar.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kitty/tab_bar.py b/kitty/tab_bar.py index a07f8dab2..bcb17c0b3 100644 --- a/kitty/tab_bar.py +++ b/kitty/tab_bar.py @@ -2,6 +2,7 @@ # vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2018, Kovid Goyal +from functools import lru_cache from typing import Any, Dict, NamedTuple, Optional, Sequence, Set, Tuple from .config import build_ansi_color_table @@ -48,6 +49,16 @@ def as_rgb(x: int) -> int: template_failures: Set[str] = set() +@lru_cache() +def compile_template(template: str) -> Any: + try: + return compile('f"""' + template + '"""', '