summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-07-06 04:13:02 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-07-06 04:32:15 +0100
commita47e18e873521627abd326bec0c26e05f5775e64 (patch)
tree8c8abe5f802bed3603eda4c8484843255b5c201b
parent0276f2adf7168ac6b77d6aa7cc86801027097625 (diff)
downloadpoezio-a47e18e873521627abd326bec0c26e05f5775e64.tar.gz
poezio-a47e18e873521627abd326bec0c26e05f5775e64.tar.bz2
poezio-a47e18e873521627abd326bec0c26e05f5775e64.tar.xz
poezio-a47e18e873521627abd326bec0c26e05f5775e64.zip
Cache results in poezio.theming.to_curses_attr.
This increases performances a *lot* compared to the previous uncached version.
-rwxr-xr-xpoezio/theming.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/poezio/theming.py b/poezio/theming.py
index 5b2546d7..0ead632e 100755
--- a/poezio/theming.py
+++ b/poezio/theming.py
@@ -69,6 +69,7 @@ log = logging.getLogger(__name__)
from poezio.config import config
import curses
+import functools
import os
from os import path
@@ -403,6 +404,7 @@ def read_tuple(_str):
char = attrs[2] if len(attrs) > 2 else '\0'
return (int(attrs[0]), int(attrs[1])), char
+@functools.lru_cache(maxsize=128)
def to_curses_attr(color_tuple):
"""
Takes a color tuple (as defined at the top of this file) and