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:
parent
52da8984c3
commit
a45d18552b
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue