From 63eaee50b8de7039de70c3fe6609203a1ac3a9fe Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 7 Apr 2014 17:33:12 +0200 Subject: [PATCH] Cache colordict/fontdict --- qutebrowser/config/style.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qutebrowser/config/style.py b/qutebrowser/config/style.py index e3aa32c47..2da6c4010 100644 --- a/qutebrowser/config/style.py +++ b/qutebrowser/config/style.py @@ -19,6 +19,8 @@ import qutebrowser.config.config as config +_colordict = None +_fontdict = None def get_stylesheet(template): """Format a stylesheet based on a template. @@ -30,10 +32,12 @@ def get_stylesheet(template): The formatted template as string. """ - cdict = config.config['colors'] - fdict = config.config['fonts'] - return template.strip().format(color=ColorDict(cdict), - font=FontDict(fdict)) + global _colordict, _fontdict + if _colordict is None: + _colordict = ColorDict(config.config['colors']) + if _fontdict is None: + _fontdict = FontDict(config.config['fonts']) + return template.strip().format(color=_colordict, font=_fontdict) class ColorDict(dict):