Skip to content

Commit

Permalink
Check if suffix is zero state earlier. Improves setup performance sig…
Browse files Browse the repository at this point in the history
…nificantly. Fixes #8
  • Loading branch information
FrederikP committed Aug 19, 2020
1 parent 7098bbb commit 06570c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ahocorapy/keywordtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,12 @@ def search_lss(self, state):
else:
traversed = traversed.longest_strict_suffix
suffix = state.longest_strict_suffix
if suffix == self._zero_state:
return
if suffix.longest_strict_suffix is None:
self.search_lss(suffix)
for symbol, next_state in suffix.transitions.items():
if (symbol not in state.transitions and
suffix != self._zero_state):
if symbol not in state.transitions:
state.transitions[symbol] = next_state

def __str__(self):
Expand Down

0 comments on commit 06570c9

Please sign in to comment.