diff roundup/backends/rdbms_common.py @ 4095:01eb89b07c13

Don't check for node's existence if we know it exists.
author Stefan Seefeld <stefan@seefeld.name>
date Thu, 12 Mar 2009 14:08:31 +0000
parents 04843a029ea1
children f4641359b892
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Thu Mar 12 10:08:17 2009 +0000
+++ b/roundup/backends/rdbms_common.py	Thu Mar 12 14:08:31 2009 +0000
@@ -1740,10 +1740,17 @@
 
                 # handle additions
                 for id in value:
+                    if id in l:
+                        continue
+                    # We can safely check this condition after
+                    # checking that this is an addition to the
+                    # multilink since the condition was checked for
+                    # existing entries at the point they were added to
+                    # the multilink.  Since the hasnode call will
+                    # result in a SQL query, it is more efficient to
+                    # avoid the check if possible.
                     if not self.db.getclass(link_class).hasnode(id):
                         raise IndexError, '%s has no node %s'%(link_class, id)
-                    if id in l:
-                        continue
                     # register the link with the newly linked node
                     if self.do_journal and self.properties[propname].do_journal:
                         self.db.addjournal(link_class, id, 'link',

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