diff roundup/backends/rdbms_common.py @ 4476:143f52d48e60

- small performance optimisation for 'get': do common case first
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 06 Apr 2011 13:29:32 +0000
parents 9b4cf6c96ee2
children 1613754d2646
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Wed Mar 30 11:20:36 2011 +0000
+++ b/roundup/backends/rdbms_common.py	Wed Apr 06 13:29:32 2011 +0000
@@ -1617,27 +1617,23 @@
 
         # 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]

Roundup Issue Tracker: http://roundup-tracker.org/