From: stefan Date: Thu, 12 Mar 2009 14:08:31 +0000 (+0000) Subject: Don't check for node's existence if we know it exists. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=381932ff00da981a9608035b6ca00ea5f4337ede;p=roundup.git Don't check for node's existence if we know it exists. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4187 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index 26f78b6..7cb90fd 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -1740,10 +1740,17 @@ class Class(hyperdb.Class): # handle additions for id in value: - if not self.db.getclass(link_class).hasnode(id): - raise IndexError, '%s has no node %s'%(link_class, id) 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) # 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',