Restructure cache to optimize critical path

This commit is contained in:
Jay Kamat 2018-10-08 23:31:07 -07:00
parent 8a48e5d2a5
commit 8bb2db5e56
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -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]