Some memory improvements with generators

This commit is contained in:
lufte 2018-08-17 01:00:32 -03:00
parent 68b9dff747
commit fd70d6d2d8

View File

@ -569,16 +569,14 @@ class RAMHandler(logging.Handler):
https://github.com/qutebrowser/qutebrowser/issues/34
"""
minlevel = LOG_LEVELS.get(level.upper(), VDEBUG_LEVEL)
lines = []
fmt = self.html_formatter.format if html else self.format
self.acquire()
try:
records = list(self._data)
lines = list(fmt(record)
for record in self._data
if record.levelno >= minlevel)
finally:
self.release()
for record in records:
if record.levelno >= minlevel:
lines.append(fmt(record))
return '\n'.join(lines)
def change_log_capacity(self, capacity):