diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index d093d5b62..20b67a3ca 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -27,6 +27,7 @@ we borrow some methods and classes from there where it makes sense. import os import os.path import textwrap +import functools import configparser import collections.abc @@ -277,6 +278,7 @@ class ConfigManager(QObject): existed = optname in sectdict if existed: del sectdict[optname] + self.get.cache_clear() return existed @cmdutils.register(name='get', instance='config', @@ -301,6 +303,7 @@ class ConfigManager(QObject): message.info("{} {} = {}".format(sectname, optname, val), immediately=True) + @functools.lru_cache() def get(self, sectname, optname, raw=False, transformed=True): """Get the value from a section/option. @@ -411,6 +414,7 @@ class ConfigManager(QObject): if sectname in ('colors', 'fonts'): self.style_changed.emit(sectname, optname) self.changed.emit(sectname, optname) + self.get.cache_clear() @cmdutils.register(instance='config') def save(self): diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py index 9ac38c832..adfd19b75 100644 --- a/qutebrowser/utils/debug.py +++ b/qutebrowser/utils/debug.py @@ -29,6 +29,7 @@ from PyQt5.QtCore import pyqtRemoveInputHook, QEvent, QCoreApplication from qutebrowser.utils import log, utils from qutebrowser.commands import cmdutils +from qutebrowser.config import config @cmdutils.register(debug=True, name='debug-set-trace') @@ -83,6 +84,11 @@ def debug_all_objects(): s = QCoreApplication.instance().get_all_objects() log.misc.debug(s) +@cmdutils.register(debug=True) +def debug_cache_stats(): + """Print config LRU cache stats.""" + info = config.instance().get.cache_info() + log.misc.debug(info) def log_events(klass): """Class decorator to log Qt events."""