Skip to content

Commit 62f2b31

Browse files
committed
Don't check for node's existence if we know it exists.
1 parent 3455da4 commit 62f2b31

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

roundup/backends/rdbms_common.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,10 +1740,17 @@ def set_inner(self, nodeid, **propvalues):
17401740

17411741
# handle additions
17421742
for id in value:
1743-
if not self.db.getclass(link_class).hasnode(id):
1744-
raise IndexError, '%s has no node %s'%(link_class, id)
17451743
if id in l:
17461744
continue
1745+
# We can safely check this condition after
1746+
# checking that this is an addition to the
1747+
# multilink since the condition was checked for
1748+
# existing entries at the point they were added to
1749+
# the multilink. Since the hasnode call will
1750+
# result in a SQL query, it is more efficient to
1751+
# avoid the check if possible.
1752+
if not self.db.getclass(link_class).hasnode(id):
1753+
raise IndexError, '%s has no node %s'%(link_class, id)
17471754
# register the link with the newly linked node
17481755
if self.do_journal and self.properties[propname].do_journal:
17491756
self.db.addjournal(link_class, id, 'link',

0 commit comments

Comments
 (0)