Some filter optimizations to avoid repeated parts of tree scan
This commit is contained in:
parent
b1af1c5435
commit
ffe9f31b0b
@ -82,7 +82,8 @@ class IsDescendantFamilyOf(Rule):
|
||||
|
||||
while expand:
|
||||
person = expand.pop(0)
|
||||
if person is None:
|
||||
if person is None or person.handle in self.matches:
|
||||
# if we have been here before, skip
|
||||
continue
|
||||
self.matches.add(person.handle)
|
||||
for family_handle in person.get_family_handle_list():
|
||||
|
@ -67,7 +67,8 @@ class IsDescendantOf(Rule):
|
||||
return person.handle in self.map
|
||||
|
||||
def init_list(self, person, first):
|
||||
if not person:
|
||||
if not person or person.handle in self.map:
|
||||
# if we have been here before, skip
|
||||
return
|
||||
if not first:
|
||||
self.map.add(person.handle)
|
||||
|
@ -61,6 +61,9 @@ class IsLessThanNthGenerationAncestorOf(Rule):
|
||||
queue = [(root_handle, 1)] # generation 1 is root
|
||||
while queue:
|
||||
handle, gen = queue.pop(0) # pop off front of queue
|
||||
if handle in self.map:
|
||||
# if we have been here before, skip
|
||||
continue
|
||||
self.map.add(handle)
|
||||
gen += 1
|
||||
if gen <= int(self.list[1]):
|
||||
|
@ -71,7 +71,8 @@ class IsLessThanNthGenerationAncestorOfBookmarked(Rule):
|
||||
def init_ancestor_list(self, handle, gen):
|
||||
# if p.get_handle() in self.map:
|
||||
# loop_error(self.orig,p)
|
||||
if not handle:
|
||||
if not handle or handle in self.map:
|
||||
# if been here already, skip
|
||||
return
|
||||
if gen:
|
||||
self.map.add(handle)
|
||||
|
@ -64,7 +64,8 @@ class IsLessThanNthGenerationAncestorOfDefaultPerson(Rule):
|
||||
def init_ancestor_list(self, handle, gen):
|
||||
# if p.get_handle() in self.map:
|
||||
# loop_error(self.orig,p)
|
||||
if not handle:
|
||||
if not handle or handle in self.map:
|
||||
# if we have been here before, skip
|
||||
return
|
||||
if gen:
|
||||
self.map.add(handle)
|
||||
|
@ -65,7 +65,8 @@ class IsLessThanNthGenerationDescendantOf(Rule):
|
||||
return person.handle in self.map
|
||||
|
||||
def init_list(self,person,gen):
|
||||
if not person:
|
||||
if not person or person.handle in self.map:
|
||||
# if we have been here before, skip
|
||||
return
|
||||
if gen:
|
||||
self.map.add(person.handle)
|
||||
|
Loading…
Reference in New Issue
Block a user