Skip to content

Commit 6a00cd7

Browse files
authored
Simplify DebugToolbar.store() (#1351)
django.utils.datastructures.SortedDict has been unused since a0569d7. Can access class variables using self so drop unnecessary type() call. range() supports passing a first argument larger than the second, in which case it doesn't yield and values. >>> list(range(2, 1)) []
1 parent 76049e6 commit 6a00cd7

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

debug_toolbar/toolbar.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,9 @@ def store(self):
9292
if self.store_id:
9393
return
9494
self.store_id = uuid.uuid4().hex
95-
cls = type(self)
96-
cls._store[self.store_id] = self
97-
for _ in range(len(cls._store) - self.config["RESULTS_CACHE_SIZE"]):
98-
try:
99-
# collections.OrderedDict
100-
cls._store.popitem(last=False)
101-
except TypeError:
102-
# django.utils.datastructures.SortedDict
103-
del cls._store[cls._store.keyOrder[0]]
95+
self._store[self.store_id] = self
96+
for _ in range(self.config["RESULTS_CACHE_SIZE"], len(self._store)):
97+
self._store.popitem(last=False)
10498

10599
@classmethod
106100
def fetch(cls, store_id):

0 commit comments

Comments
 (0)