Code

- small performance optimisation for 'get': do common case first
authorschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Wed, 6 Apr 2011 13:29:32 +0000 (13:29 +0000)
committerschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Wed, 6 Apr 2011 13:29:32 +0000 (13:29 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4585 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/backends/rdbms_common.py

index b37f164dd42bd67a3fd2f03d247dc6a1d5419ab0..3ba789897e29cc8a92ce354fec182c09e25e0a52 100644 (file)
@@ -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]