From 8bb2db5e56fb1553287bb1eb07f49f37438c8562 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Mon, 8 Oct 2018 23:31:07 -0700 Subject: [PATCH] Restructure cache to optimize critical path --- qutebrowser/config/configcache.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/configcache.py b/qutebrowser/config/configcache.py index a421ba85c..15f343478 100644 --- a/qutebrowser/config/configcache.py +++ b/qutebrowser/config/configcache.py @@ -46,7 +46,9 @@ class ConfigCache: self._cache[attr] = config.instance.get(attr) def __getitem__(self, attr: str) -> typing.Any: - if attr not in self._cache: + try: + return self._cache[attr] + except KeyError: assert not config.instance.get_opt(attr).supports_pattern self._cache[attr] = config.instance.get(attr) - return self._cache[attr] + return self._cache[attr]