Skip to content

Commit

Permalink
[settings perf-] Cache sheet obj instead of name in _mappings
Browse files Browse the repository at this point in the history
Sheet names can change between creations of the cache.

d362033
  • Loading branch information
anjakefala committed Dec 2, 2023
1 parent f14f059 commit 81221c4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions visidata/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _mappings(self, obj):
'''
mappings = []
if obj:
mappings += [self.objname(obj)]
mappings += [obj]
mappings += [self.objname(cls) for cls in inspect.getmro(type(obj))]

mappings += ['global', 'default']
Expand All @@ -83,7 +83,7 @@ def _get(self, key, obj=None):
d = self.get(key, None)
if d:
for m in self._mappings(obj or vd.activeSheet):
v = d.get(m)
v = d.get(self.objname(m))
if v:
return v

Expand All @@ -93,6 +93,7 @@ def iter(self, obj=None):
obj = vd.activeSheet

for o in self._mappings(obj):
o = self.objname(o)
for k in self.keys():
for o2 in self[k]:
if o == o2:
Expand Down

0 comments on commit 81221c4

Please # to comment.