micro optimization

This commit is contained in:
j 2016-03-17 16:03:03 +01:00
parent 8c23d73bd3
commit ebc0f28799

View file

@ -127,14 +127,15 @@ class Item(db.Model):
state.db.session.execute(q)
def json(self, keys=None):
j = {}
j = {}
j['id'] = self.id
j['created'] = self.created
j['modified'] = self.modified
j['timesaccessed'] = self.timesaccessed
j['accessed'] = self.accessed
j['added'] = self.added
if state.downloads and not state.shutdown:
if (not keys or 'transferadded' in keys or 'transferprogress' in keys) \
and state.downloads and not state.shutdown:
t = state.downloads.transfers.get(self.id)
if t:
j['transferadded'] = t['added']
@ -149,7 +150,9 @@ class Item(db.Model):
j[key] = self.info[key]
if self.meta:
j.update(self.meta)
for key in self.meta:
if not keys or key in keys:
j[key] = self.meta[key]
for key in self.id_keys:
if key not in self.meta and key in j: