Handle dirs only once

Time: 5.73s/5.88s => 5.36s

(Before rebase: 4.86s => 4.45s)
This commit is contained in:
Daniel Hahler 2018-10-25 17:19:19 +02:00
parent 2b50911c9d
commit 6ffa347c77
1 changed files with 11 additions and 7 deletions

View File

@ -529,10 +529,14 @@ class Session(nodes.FSCollector):
def filter_(f): def filter_(f):
return f.check(file=1) return f.check(file=1)
seen_dirs = set()
for path in argpath.visit( for path in argpath.visit(
fil=filter_, rec=self._recurse, bf=True, sort=True fil=filter_, rec=self._recurse, bf=True, sort=True
): ):
pkginit = path.dirpath().join("__init__.py") dirpath = path.dirpath()
if dirpath not in seen_dirs:
seen_dirs.add(dirpath)
pkginit = dirpath.join("__init__.py")
if pkginit.exists() and not any( if pkginit.exists() and not any(
x in parts(pkginit.strpath) for x in paths x in parts(pkginit.strpath) for x in paths
): ):