Some filter optimizations to avoid repeated parts of tree scan

This commit is contained in:
prculley 2017-11-28 09:37:48 -06:00 committed by Nick Hall
parent b1af1c5435
commit ffe9f31b0b
6 changed files with 13 additions and 5 deletions

View File

@ -82,7 +82,8 @@ class IsDescendantFamilyOf(Rule):
while expand: while expand:
person = expand.pop(0) 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 continue
self.matches.add(person.handle) self.matches.add(person.handle)
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():

View File

@ -67,7 +67,8 @@ class IsDescendantOf(Rule):
return person.handle in self.map return person.handle in self.map
def init_list(self, person, first): 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 return
if not first: if not first:
self.map.add(person.handle) self.map.add(person.handle)

View File

@ -61,6 +61,9 @@ class IsLessThanNthGenerationAncestorOf(Rule):
queue = [(root_handle, 1)] # generation 1 is root queue = [(root_handle, 1)] # generation 1 is root
while queue: while queue:
handle, gen = queue.pop(0) # pop off front of 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) self.map.add(handle)
gen += 1 gen += 1
if gen <= int(self.list[1]): if gen <= int(self.list[1]):

View File

@ -71,7 +71,8 @@ class IsLessThanNthGenerationAncestorOfBookmarked(Rule):
def init_ancestor_list(self, handle, gen): def init_ancestor_list(self, handle, gen):
# if p.get_handle() in self.map: # if p.get_handle() in self.map:
# loop_error(self.orig,p) # loop_error(self.orig,p)
if not handle: if not handle or handle in self.map:
# if been here already, skip
return return
if gen: if gen:
self.map.add(handle) self.map.add(handle)

View File

@ -64,7 +64,8 @@ class IsLessThanNthGenerationAncestorOfDefaultPerson(Rule):
def init_ancestor_list(self, handle, gen): def init_ancestor_list(self, handle, gen):
# if p.get_handle() in self.map: # if p.get_handle() in self.map:
# loop_error(self.orig,p) # loop_error(self.orig,p)
if not handle: if not handle or handle in self.map:
# if we have been here before, skip
return return
if gen: if gen:
self.map.add(handle) self.map.add(handle)

View File

@ -65,7 +65,8 @@ class IsLessThanNthGenerationDescendantOf(Rule):
return person.handle in self.map return person.handle in self.map
def init_list(self,person,gen): 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 return
if gen: if gen:
self.map.add(person.handle) self.map.add(person.handle)