From baf888b4cae34fe78067ce54099db284e964829a Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Wed, 6 Apr 2011 13:29:32 +0000 Subject: [PATCH] - small performance optimisation for 'get': do common case first git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4585 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/rdbms_common.py | 38 ++++++++++++++------------------ 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index b37f164..3ba7898 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -1617,27 +1617,23 @@ class Class(hyperdb.Class): # get the node's dict d = self.db.getnode(self.classname, nodeid) - - if propname == 'creation': - if 'creation' in d: - return d['creation'] - else: - return date.Date() - if propname == 'activity': - if 'activity' in d: - return d['activity'] - else: - return date.Date() - if propname == 'creator': - if 'creator' in d: - return d['creator'] - else: - return self.db.getuid() - if propname == 'actor': - if 'actor' in d: - return d['actor'] - else: - return self.db.getuid() + # handle common case -- that property is in dict -- first + # if None and one of creator/creation actor/activity return None + if propname in d: + r = d [propname] + # return copy of our list + if isinstance (r, list): + return r[:] + if r is not None: + return r + elif propname in ('creation', 'activity', 'creator', 'actor'): + return r + + # propname not in d: + if propname == 'creation' or propname == 'activity': + return date.Date() + if propname == 'creator' or propname == 'actor': + return self.db.getuid() # get the property (raises KeyError if invalid) prop = self.properties[propname] -- 2.30.2