Skip to content

Commit 06444c1

Browse files
author
Ralf Schlatterbeck
committed
- small performance optimisation for 'get': do common case first
1 parent 4c1bcb0 commit 06444c1

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

roundup/backends/rdbms_common.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,27 +1617,23 @@ def get(self, nodeid, propname, default=_marker, cache=1):
16171617

16181618
# get the node's dict
16191619
d = self.db.getnode(self.classname, nodeid)
1620-
1621-
if propname == 'creation':
1622-
if 'creation' in d:
1623-
return d['creation']
1624-
else:
1625-
return date.Date()
1626-
if propname == 'activity':
1627-
if 'activity' in d:
1628-
return d['activity']
1629-
else:
1630-
return date.Date()
1631-
if propname == 'creator':
1632-
if 'creator' in d:
1633-
return d['creator']
1634-
else:
1635-
return self.db.getuid()
1636-
if propname == 'actor':
1637-
if 'actor' in d:
1638-
return d['actor']
1639-
else:
1640-
return self.db.getuid()
1620+
# handle common case -- that property is in dict -- first
1621+
# if None and one of creator/creation actor/activity return None
1622+
if propname in d:
1623+
r = d [propname]
1624+
# return copy of our list
1625+
if isinstance (r, list):
1626+
return r[:]
1627+
if r is not None:
1628+
return r
1629+
elif propname in ('creation', 'activity', 'creator', 'actor'):
1630+
return r
1631+
1632+
# propname not in d:
1633+
if propname == 'creation' or propname == 'activity':
1634+
return date.Date()
1635+
if propname == 'creator' or propname == 'actor':
1636+
return self.db.getuid()
16411637

16421638
# get the property (raises KeyError if invalid)
16431639
prop = self.properties[propname]

0 commit comments

Comments
 (0)