From a47e18e873521627abd326bec0c26e05f5775e64 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 6 Jul 2016 04:13:02 +0100 Subject: Cache results in poezio.theming.to_curses_attr. This increases performances a *lot* compared to the previous uncached version. --- poezio/theming.py | 2 ++ 1 file changed, 2 insertions(+) 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 -- cgit v1.2.3 From 69b4480e9e6ff578b880b7d8089616bc68e60f71 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 6 Jul 2016 04:23:31 +0100 Subject: Make UserList.refresh_if_possible not hyper dumb. This function was actually calling refresh for every single item that was different from the cached version. --- poezio/windows/muc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/poezio/windows/muc.py b/poezio/windows/muc.py index 897b9f81..ee57ab6e 100644 --- a/poezio/windows/muc.py +++ b/poezio/windows/muc.py @@ -47,10 +47,11 @@ class UserList(Win): self.cache = new self.refresh(users) return - for i in range(len(old)): - if old[i] != new[i]: + for a, b in zip(old, new): + if a != b: self.cache = new self.refresh(users) + return def refresh(self, users): log.debug('Refresh: %s', self.__class__.__name__) -- cgit v1.2.3