Find child id once

Rather than computing the child id for every iteration of walking
backwards, we do it once.
This commit is contained in:
Bryan Schumaker 2010-11-10 08:22:33 -05:00
parent 52da8984c3
commit a45d18552b
1 changed files with 2 additions and 1 deletions

View File

@ -55,7 +55,8 @@ class DLTree(Tree):
def walk_backwards(self, child = None):
key = None
if child != None:
key = [item[0] for item in self.items() if id(item[1]) == id(child)]
idc = id(child)
key = [i[0] for i in self.items() if id(i[1]) == idc]
if self.parent == None:
return key
ret = self.parent.walk_backwards(self)