class _FileMatcher(object): def __init__(self, files): self.matcher = HelperMatcher(files, _DoesFileMatch()) self.slash_count = 0 def find_matches(self, starting): slash_count = starting.count('/') if slash_count != self.slash_count: self.matcher.invalidate() self.slash_count = slash_count return self.matcher.find_matches(starting)