From dfd60426d8da06c817c6d3f71901b4f1c013a819 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 8 May 2015 20:37:21 +0200 Subject: Micro-optimizations on refresh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduce the number of calls to config.get whenever possible. Yields a performance improvement of at least 10% for the basic use case of "receiving a message in the current tab". Logging stuff isn’t free either, even when the call should be a no-op, so we should try to make the debug log less verbose. --- src/windows/info_bar.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/windows/info_bar.py') diff --git a/src/windows/info_bar.py b/src/windows/info_bar.py index e66343c5..abd956cd 100644 --- a/src/windows/info_bar.py +++ b/src/windows/info_bar.py @@ -28,6 +28,7 @@ class GlobalInfoBar(Win): show_names = config.get('show_tab_names') show_nums = config.get('show_tab_numbers') use_nicks = config.get('use_tab_nicks') + show_inactive = config.get('show_inactive_tabs') # ignore any remaining gap tabs if the feature is not enabled if create_gaps: sorted_tabs = self.core.tabs[:] @@ -37,8 +38,7 @@ class GlobalInfoBar(Win): for nb, tab in enumerate(sorted_tabs): if not tab: continue color = tab.color - if not config.get('show_inactive_tabs') and\ - color is get_theme().COLOR_TAB_NORMAL: + if not show_inactive and color is get_theme().COLOR_TAB_NORMAL: continue try: if show_nums or not show_names: @@ -87,9 +87,10 @@ class VerticalGlobalInfoBar(Win): sorted_tabs = sorted_tabs[-height:] else: sorted_tabs = sorted_tabs[pos-height//2 : pos+height//2] + asc_sort = (config.get('vertical_tab_list_sort') == 'asc') for y, tab in enumerate(sorted_tabs): color = tab.vertical_color - if not config.get('vertical_tab_list_sort') != 'asc': + if asc_sort: y = height - y - 1 self.addstr(y, 0, "%2d" % tab.nb, to_curses_attr(get_theme().COLOR_VERTICAL_TAB_NUMBER)) -- cgit v1.2.3